<!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>[208310] trunk/Source/WebCore</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/208310">208310</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2016-11-02 16:04:22 -0700 (Wed, 02 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Give IDBKey(Data) a WTF::Variant overhaul.
https://bugs.webkit.org/show_bug.cgi?id=164332

Reviewed by Alex Christensen and Andy Estes.

No new tests (Refactor, no behavior change).

* Modules/indexeddb/IDBKey.cpp:
(WebCore::IDBKey::IDBKey):
(WebCore::IDBKey::isValid):
(WebCore::IDBKey::compare):
* Modules/indexeddb/IDBKey.h:
(WebCore::IDBKey::array):
(WebCore::IDBKey::string):
(WebCore::IDBKey::date):
(WebCore::IDBKey::number):
(WebCore::IDBKey::IDBKey): Deleted.

* Modules/indexeddb/IDBKeyData.cpp:
(WebCore::IDBKeyData::IDBKeyData):
(WebCore::IDBKeyData::maybeCreateIDBKey):
(WebCore::IDBKeyData::isolatedCopy):
(WebCore::IDBKeyData::encode):
(WebCore::IDBKeyData::decode):
(WebCore::IDBKeyData::compare):
(WebCore::IDBKeyData::loggingString):
(WebCore::IDBKeyData::setArrayValue):
(WebCore::IDBKeyData::setStringValue):
(WebCore::IDBKeyData::setDateValue):
(WebCore::IDBKeyData::setNumberValue):
(WebCore::IDBKeyData::operator==):
* Modules/indexeddb/IDBKeyData.h:
(WebCore::IDBKeyData::hash):
(WebCore::IDBKeyData::string):
(WebCore::IDBKeyData::date):
(WebCore::IDBKeyData::number):
(WebCore::IDBKeyData::array):
(WebCore::IDBKeyData::encode):
(WebCore::IDBKeyData::decode):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBKeycpp">trunk/Source/WebCore/Modules/indexeddb/IDBKey.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBKeyh">trunk/Source/WebCore/Modules/indexeddb/IDBKey.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBKeyDatacpp">trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBKeyDatah">trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208309 => 208310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-02 22:19:39 UTC (rev 208309)
+++ trunk/Source/WebCore/ChangeLog        2016-11-02 23:04:22 UTC (rev 208310)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2016-11-02  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Give IDBKey(Data) a WTF::Variant overhaul.
+        https://bugs.webkit.org/show_bug.cgi?id=164332
+
+        Reviewed by Alex Christensen and Andy Estes.
+
+        No new tests (Refactor, no behavior change).
+
+        * Modules/indexeddb/IDBKey.cpp:
+        (WebCore::IDBKey::IDBKey):
+        (WebCore::IDBKey::isValid):
+        (WebCore::IDBKey::compare):
+        * Modules/indexeddb/IDBKey.h:
+        (WebCore::IDBKey::array):
+        (WebCore::IDBKey::string):
+        (WebCore::IDBKey::date):
+        (WebCore::IDBKey::number):
+        (WebCore::IDBKey::IDBKey): Deleted.
+
+        * Modules/indexeddb/IDBKeyData.cpp:
+        (WebCore::IDBKeyData::IDBKeyData):
+        (WebCore::IDBKeyData::maybeCreateIDBKey):
+        (WebCore::IDBKeyData::isolatedCopy):
+        (WebCore::IDBKeyData::encode):
+        (WebCore::IDBKeyData::decode):
+        (WebCore::IDBKeyData::compare):
+        (WebCore::IDBKeyData::loggingString):
+        (WebCore::IDBKeyData::setArrayValue):
+        (WebCore::IDBKeyData::setStringValue):
+        (WebCore::IDBKeyData::setDateValue):
+        (WebCore::IDBKeyData::setNumberValue):
+        (WebCore::IDBKeyData::operator==):
+        * Modules/indexeddb/IDBKeyData.h:
+        (WebCore::IDBKeyData::hash):
+        (WebCore::IDBKeyData::string):
+        (WebCore::IDBKeyData::date):
+        (WebCore::IDBKeyData::number):
+        (WebCore::IDBKeyData::array):
+        (WebCore::IDBKeyData::encode):
+        (WebCore::IDBKeyData::decode):
+
</ins><span class="cx"> 2016-11-01  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [WebIDL] Move interfaces and typed arrays over to JSDOMConvert
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBKeycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKey.cpp (208309 => 208310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBKey.cpp        2016-11-02 22:19:39 UTC (rev 208309)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKey.cpp        2016-11-02 23:04:22 UTC (rev 208310)
</span><span class="lines">@@ -32,6 +32,29 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+using IDBKeyVector = Vector&lt;RefPtr&lt;IDBKey&gt;&gt;;
+
+IDBKey::IDBKey(KeyType type, double number)
+    : m_type(type)
+    , m_value(number)
+    , m_sizeEstimate(OverheadSize + sizeof(double))
+{
+}
+
+IDBKey::IDBKey(const String&amp; value)
+    : m_type(KeyType::String)
+    , m_value(value)
+    , m_sizeEstimate(OverheadSize + value.length() * sizeof(UChar))
+{
+}
+
+IDBKey::IDBKey(const IDBKeyVector&amp; keyArray, size_t arraySize)
+    : m_type(KeyType::Array)
+    , m_value(keyArray)
+    , m_sizeEstimate(OverheadSize + arraySize)
+{
+}
+
</ins><span class="cx"> IDBKey::~IDBKey()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -42,7 +65,7 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (m_type == KeyType::Array) {
</span><del>-        for (auto&amp; key : m_array) {
</del><ins>+        for (auto&amp; key : WTF::get&lt;IDBKeyVector&gt;(m_value)) {
</ins><span class="cx">             if (!key-&gt;isValid())
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="lines">@@ -57,21 +80,27 @@
</span><span class="cx">         return m_type &gt; other.m_type ? -1 : 1;
</span><span class="cx"> 
</span><span class="cx">     switch (m_type) {
</span><del>-    case KeyType::Array:
-        for (size_t i = 0; i &lt; m_array.size() &amp;&amp; i &lt; other.m_array.size(); ++i) {
-            if (int result = m_array[i]-&gt;compare(*other.m_array[i]))
</del><ins>+    case KeyType::Array: {
+        auto&amp; array = WTF::get&lt;IDBKeyVector&gt;(m_value);
+        auto&amp; otherArray = WTF::get&lt;IDBKeyVector&gt;(other.m_value);
+        for (size_t i = 0; i &lt; array.size() &amp;&amp; i &lt; otherArray.size(); ++i) {
+            if (int result = array[i]-&gt;compare(*otherArray[i]))
</ins><span class="cx">                 return result;
</span><span class="cx">         }
</span><del>-        if (m_array.size() &lt; other.m_array.size())
</del><ins>+        if (array.size() &lt; otherArray.size())
</ins><span class="cx">             return -1;
</span><del>-        if (m_array.size() &gt; other.m_array.size())
</del><ins>+        if (array.size() &gt; otherArray.size())
</ins><span class="cx">             return 1;
</span><span class="cx">         return 0;
</span><ins>+    }
</ins><span class="cx">     case KeyType::String:
</span><del>-        return -codePointCompare(other.m_string, m_string);
</del><ins>+        return -codePointCompare(WTF::get&lt;String&gt;(other.m_value), WTF::get&lt;String&gt;(m_value));
</ins><span class="cx">     case KeyType::Date:
</span><del>-    case KeyType::Number:
-        return (m_number &lt; other.m_number) ? -1 : ((m_number &gt; other. m_number) ? 1 : 0);
</del><ins>+    case KeyType::Number: {
+        auto number = WTF::get&lt;double&gt;(m_value);
+        auto otherNumber = WTF::get&lt;double&gt;(other.m_value);
+        return (number &lt; otherNumber) ? -1 : ((number &gt; otherNumber) ? 1 : 0);
+    }
</ins><span class="cx">     case KeyType::Invalid:
</span><span class="cx">     case KeyType::Min:
</span><span class="cx">     case KeyType::Max:
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBKeyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKey.h (208309 => 208310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBKey.h        2016-11-02 22:19:39 UTC (rev 208309)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKey.h        2016-11-02 23:04:22 UTC (rev 208310)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include &quot;IndexedDB.h&quot;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><ins>+#include &lt;wtf/Variant.h&gt;
</ins><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -103,25 +104,25 @@
</span><span class="cx">     const Vector&lt;RefPtr&lt;IDBKey&gt;&gt;&amp; array() const
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_type == KeyType::Array);
</span><del>-        return m_array;
</del><ins>+        return WTF::get&lt;Vector&lt;RefPtr&lt;IDBKey&gt;&gt;&gt;(m_value);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     const String&amp; string() const
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_type == KeyType::String);
</span><del>-        return m_string;
</del><ins>+        return WTF::get&lt;String&gt;(m_value);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     double date() const
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_type == KeyType::Date);
</span><del>-        return m_number;
</del><ins>+        return WTF::get&lt;double&gt;(m_value);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     double number() const
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_type == KeyType::Number);
</span><del>-        return m_number;
</del><ins>+        return WTF::get&lt;double&gt;(m_value);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     int compare(const IDBKey&amp; other) const;
</span><span class="lines">@@ -143,15 +144,18 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    IDBKey() : m_type(KeyType::Invalid), m_number(0), m_sizeEstimate(OverheadSize) { }
-    IDBKey(KeyType type, double number) : m_type(type), m_number(number), m_sizeEstimate(OverheadSize + sizeof(double)) { }
-    explicit IDBKey(const String&amp; value) : m_type(KeyType::String), m_string(value), m_number(0), m_sizeEstimate(OverheadSize + value.length() * sizeof(UChar)) { }
-    IDBKey(const Vector&lt;RefPtr&lt;IDBKey&gt;&gt;&amp; keyArray, size_t arraySize) : m_type(KeyType::Array), m_array(keyArray), m_number(0), m_sizeEstimate(OverheadSize + arraySize) { }
</del><ins>+    IDBKey()
+        : m_type(KeyType::Invalid)
+        , m_sizeEstimate(OverheadSize)
+    {
+    }
</ins><span class="cx"> 
</span><ins>+    IDBKey(KeyType, double number);
+    explicit IDBKey(const String&amp; value);
+    IDBKey(const Vector&lt;RefPtr&lt;IDBKey&gt;&gt;&amp; keyArray, size_t arraySize);
+
</ins><span class="cx">     const KeyType m_type;
</span><del>-    const Vector&lt;RefPtr&lt;IDBKey&gt;&gt; m_array;
-    const String m_string;
-    const double m_number;
</del><ins>+    Variant&lt;Vector&lt;RefPtr&lt;IDBKey&gt;&gt;, String, double&gt; m_value;
</ins><span class="cx"> 
</span><span class="cx">     const size_t m_sizeEstimate;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBKeyDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp (208309 => 208310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp        2016-11-02 22:19:39 UTC (rev 208309)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp        2016-11-02 23:04:22 UTC (rev 208310)
</span><span class="lines">@@ -46,18 +46,21 @@
</span><span class="cx">     switch (m_type) {
</span><span class="cx">     case KeyType::Invalid:
</span><span class="cx">         break;
</span><del>-    case KeyType::Array:
</del><ins>+    case KeyType::Array: {
+        m_value = Vector&lt;IDBKeyData&gt;();
+        auto&amp; array = WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(m_value);
</ins><span class="cx">         for (auto&amp; key2 : key-&gt;array())
</span><del>-            m_arrayValue.append(IDBKeyData(key2.get()));
</del><ins>+            array.append(IDBKeyData(key2.get()));
</ins><span class="cx">         break;
</span><ins>+    }
</ins><span class="cx">     case KeyType::String:
</span><del>-        m_stringValue = key-&gt;string();
</del><ins>+        m_value = key-&gt;string();
</ins><span class="cx">         break;
</span><span class="cx">     case KeyType::Date:
</span><del>-        m_numberValue = key-&gt;date();
</del><ins>+        m_value = key-&gt;date();
</ins><span class="cx">         break;
</span><span class="cx">     case KeyType::Number:
</span><del>-        m_numberValue = key-&gt;number();
</del><ins>+        m_value = key-&gt;number();
</ins><span class="cx">         break;
</span><span class="cx">     case KeyType::Max:
</span><span class="cx">     case KeyType::Min:
</span><span class="lines">@@ -73,21 +76,20 @@
</span><span class="cx">     switch (m_type) {
</span><span class="cx">     case KeyType::Invalid:
</span><span class="cx">         return IDBKey::createInvalid();
</span><del>-    case KeyType::Array:
-        {
-            Vector&lt;RefPtr&lt;IDBKey&gt;&gt; array;
-            for (auto&amp; keyData : m_arrayValue) {
-                array.append(keyData.maybeCreateIDBKey());
-                ASSERT(array.last());
-            }
-            return IDBKey::createArray(array);
</del><ins>+    case KeyType::Array: {
+        Vector&lt;RefPtr&lt;IDBKey&gt;&gt; array;
+        for (auto&amp; keyData : WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(m_value)) {
+            array.append(keyData.maybeCreateIDBKey());
+            ASSERT(array.last());
</ins><span class="cx">         }
</span><ins>+        return IDBKey::createArray(array);
+    }
</ins><span class="cx">     case KeyType::String:
</span><del>-        return IDBKey::createString(m_stringValue);
</del><ins>+        return IDBKey::createString(WTF::get&lt;String&gt;(m_value));
</ins><span class="cx">     case KeyType::Date:
</span><del>-        return IDBKey::createDate(m_numberValue);
</del><ins>+        return IDBKey::createDate(WTF::get&lt;double&gt;(m_value));
</ins><span class="cx">     case KeyType::Number:
</span><del>-        return IDBKey::createNumber(m_numberValue);
</del><ins>+        return IDBKey::createNumber(WTF::get&lt;double&gt;(m_value));
</ins><span class="cx">     case KeyType::Max:
</span><span class="cx">     case KeyType::Min:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="lines">@@ -116,16 +118,19 @@
</span><span class="cx">     switch (source.m_type) {
</span><span class="cx">     case KeyType::Invalid:
</span><span class="cx">         return;
</span><del>-    case KeyType::Array:
-        for (auto&amp; key : source.m_arrayValue)
-            destination.m_arrayValue.append(key.isolatedCopy());
</del><ins>+    case KeyType::Array: {
+        destination.m_value = Vector&lt;IDBKeyData&gt;();
+        auto&amp; destinationArray = WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(destination.m_value);
+        for (auto&amp; key : WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(source.m_value))
+            destinationArray.append(key.isolatedCopy());
</ins><span class="cx">         return;
</span><ins>+    }
</ins><span class="cx">     case KeyType::String:
</span><del>-        destination.m_stringValue = source.m_stringValue.isolatedCopy();
</del><ins>+        destination.m_value = WTF::get&lt;String&gt;(source.m_value).isolatedCopy();
</ins><span class="cx">         return;
</span><span class="cx">     case KeyType::Date:
</span><span class="cx">     case KeyType::Number:
</span><del>-        destination.m_numberValue = source.m_numberValue;
</del><ins>+        destination.m_value = WTF::get&lt;double&gt;(source.m_value);
</ins><span class="cx">         return;
</span><span class="cx">     case KeyType::Max:
</span><span class="cx">     case KeyType::Min:
</span><span class="lines">@@ -146,17 +151,19 @@
</span><span class="cx">     switch (m_type) {
</span><span class="cx">     case KeyType::Invalid:
</span><span class="cx">         return;
</span><del>-    case KeyType::Array:
-        encoder.encodeObjects(&quot;array&quot;, m_arrayValue.begin(), m_arrayValue.end(), [](KeyedEncoder&amp; encoder, const IDBKeyData&amp; key) {
</del><ins>+    case KeyType::Array: {
+        auto&amp; array = WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(m_value);
+        encoder.encodeObjects(&quot;array&quot;, array.begin(), array.end(), [](KeyedEncoder&amp; encoder, const IDBKeyData&amp; key) {
</ins><span class="cx">             key.encode(encoder);
</span><span class="cx">         });
</span><span class="cx">         return;
</span><ins>+    }
</ins><span class="cx">     case KeyType::String:
</span><del>-        encoder.encodeString(&quot;string&quot;, m_stringValue);
</del><ins>+        encoder.encodeString(&quot;string&quot;, WTF::get&lt;String&gt;(m_value));
</ins><span class="cx">         return;
</span><span class="cx">     case KeyType::Date:
</span><span class="cx">     case KeyType::Number:
</span><del>-        encoder.encodeDouble(&quot;number&quot;, m_numberValue);
</del><ins>+        encoder.encodeDouble(&quot;number&quot;, WTF::get&lt;double&gt;(m_value));
</ins><span class="cx">         return;
</span><span class="cx">     case KeyType::Max:
</span><span class="cx">     case KeyType::Min:
</span><span class="lines">@@ -195,11 +202,15 @@
</span><span class="cx">     if (result.m_type == KeyType::Min)
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    if (result.m_type == KeyType::String)
-        return decoder.decodeString(&quot;string&quot;, result.m_stringValue);
</del><ins>+    if (result.m_type == KeyType::String) {
+        result.m_value = String();
+        return decoder.decodeString(&quot;string&quot;, WTF::get&lt;String&gt;(result.m_value));
+    }
</ins><span class="cx"> 
</span><del>-    if (result.m_type == KeyType::Number || result.m_type == KeyType::Date)
-        return decoder.decodeDouble(&quot;number&quot;, result.m_numberValue);
</del><ins>+    if (result.m_type == KeyType::Number || result.m_type == KeyType::Date) {
+        result.m_value = 0.0;
+        return decoder.decodeDouble(&quot;number&quot;, WTF::get&lt;double&gt;(result.m_value));
+    }
</ins><span class="cx"> 
</span><span class="cx">     ASSERT(result.m_type == KeyType::Array);
</span><span class="cx"> 
</span><span class="lines">@@ -207,8 +218,8 @@
</span><span class="cx">         return decode(decoder, result);
</span><span class="cx">     };
</span><span class="cx">     
</span><del>-    result.m_arrayValue.clear();
-    return decoder.decodeObjects(&quot;array&quot;, result.m_arrayValue, arrayFunction);
</del><ins>+    result.m_value = Vector&lt;IDBKeyData&gt;();
+    return decoder.decodeObjects(&quot;array&quot;, WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(result.m_value), arrayFunction);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int IDBKeyData::compare(const IDBKeyData&amp; other) const
</span><span class="lines">@@ -231,23 +242,30 @@
</span><span class="cx">         // Invalid type should have been fully handled above
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         return 0;
</span><del>-    case KeyType::Array:
-        for (size_t i = 0; i &lt; m_arrayValue.size() &amp;&amp; i &lt; other.m_arrayValue.size(); ++i) {
-            if (int result = m_arrayValue[i].compare(other.m_arrayValue[i]))
</del><ins>+    case KeyType::Array: {
+        auto&amp; array = WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(m_value);
+        auto&amp; otherArray = WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(other.m_value);
+        for (size_t i = 0; i &lt; array.size() &amp;&amp; i &lt; otherArray.size(); ++i) {
+            if (int result = array[i].compare(otherArray[i]))
</ins><span class="cx">                 return result;
</span><span class="cx">         }
</span><del>-        if (m_arrayValue.size() &lt; other.m_arrayValue.size())
</del><ins>+        if (array.size() &lt; otherArray.size())
</ins><span class="cx">             return -1;
</span><del>-        if (m_arrayValue.size() &gt; other.m_arrayValue.size())
</del><ins>+        if (array.size() &gt; otherArray.size())
</ins><span class="cx">             return 1;
</span><span class="cx">         return 0;
</span><ins>+    }
</ins><span class="cx">     case KeyType::String:
</span><del>-        return codePointCompare(m_stringValue, other.m_stringValue);
</del><ins>+        return codePointCompare(WTF::get&lt;String&gt;(m_value), WTF::get&lt;String&gt;(other.m_value));
</ins><span class="cx">     case KeyType::Date:
</span><del>-    case KeyType::Number:
-        if (m_numberValue == other.m_numberValue)
</del><ins>+    case KeyType::Number: {
+        auto number = WTF::get&lt;double&gt;(m_value);
+        auto otherNumber = WTF::get&lt;double&gt;(other.m_value);
+
+        if (number == otherNumber)
</ins><span class="cx">             return 0;
</span><del>-        return m_numberValue &gt; other.m_numberValue ? 1 : -1;
</del><ins>+        return number &gt; otherNumber ? 1 : -1;
+    }
</ins><span class="cx">     case KeyType::Max:
</span><span class="cx">     case KeyType::Min:
</span><span class="cx">         return 0;
</span><span class="lines">@@ -271,9 +289,10 @@
</span><span class="cx">     case KeyType::Array: {
</span><span class="cx">         StringBuilder builder;
</span><span class="cx">         builder.appendLiteral(&quot;&lt;array&gt; - { &quot;);
</span><del>-        for (size_t i = 0; i &lt; m_arrayValue.size(); ++i) {
-            builder.append(m_arrayValue[i].loggingString());
-            if (i &lt; m_arrayValue.size() - 1)
</del><ins>+        auto&amp; array = WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(m_value);
+        for (size_t i = 0; i &lt; array.size(); ++i) {
+            builder.append(array[i].loggingString());
+            if (i &lt; array.size() - 1)
</ins><span class="cx">                 builder.appendLiteral(&quot;, &quot;);
</span><span class="cx">         }
</span><span class="cx">         builder.appendLiteral(&quot; }&quot;);
</span><span class="lines">@@ -281,12 +300,12 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case KeyType::String:
</span><del>-        result = &quot;&lt;string&gt; - &quot; + m_stringValue;
</del><ins>+        result = &quot;&lt;string&gt; - &quot; + WTF::get&lt;String&gt;(m_value);
</ins><span class="cx">         break;
</span><span class="cx">     case KeyType::Date:
</span><del>-        return String::format(&quot;&lt;date&gt; - %f&quot;, m_numberValue);
</del><ins>+        return String::format(&quot;&lt;date&gt; - %f&quot;, WTF::get&lt;double&gt;(m_value));
</ins><span class="cx">     case KeyType::Number:
</span><del>-        return String::format(&quot;&lt;number&gt; - %f&quot;, m_numberValue);
</del><ins>+        return String::format(&quot;&lt;number&gt; - %f&quot;, WTF::get&lt;double&gt;(m_value));
</ins><span class="cx">     case KeyType::Max:
</span><span class="cx">         return &quot;&lt;maximum&gt;&quot;;
</span><span class="cx">     case KeyType::Min:
</span><span class="lines">@@ -307,7 +326,7 @@
</span><span class="cx"> void IDBKeyData::setArrayValue(const Vector&lt;IDBKeyData&gt;&amp; value)
</span><span class="cx"> {
</span><span class="cx">     *this = IDBKeyData();
</span><del>-    m_arrayValue = value;
</del><ins>+    m_value = value;
</ins><span class="cx">     m_type = KeyType::Array;
</span><span class="cx">     m_isNull = false;
</span><span class="cx"> }
</span><span class="lines">@@ -315,7 +334,7 @@
</span><span class="cx"> void IDBKeyData::setStringValue(const String&amp; value)
</span><span class="cx"> {
</span><span class="cx">     *this = IDBKeyData();
</span><del>-    m_stringValue = value;
</del><ins>+    m_value = value;
</ins><span class="cx">     m_type = KeyType::String;
</span><span class="cx">     m_isNull = false;
</span><span class="cx"> }
</span><span class="lines">@@ -323,7 +342,7 @@
</span><span class="cx"> void IDBKeyData::setDateValue(double value)
</span><span class="cx"> {
</span><span class="cx">     *this = IDBKeyData();
</span><del>-    m_numberValue = value;
</del><ins>+    m_value = value;
</ins><span class="cx">     m_type = KeyType::Date;
</span><span class="cx">     m_isNull = false;
</span><span class="cx"> }
</span><span class="lines">@@ -331,7 +350,7 @@
</span><span class="cx"> void IDBKeyData::setNumberValue(double value)
</span><span class="cx"> {
</span><span class="cx">     *this = IDBKeyData();
</span><del>-    m_numberValue = value;
</del><ins>+    m_value = value;
</ins><span class="cx">     m_type = KeyType::Number;
</span><span class="cx">     m_isNull = false;
</span><span class="cx"> }
</span><span class="lines">@@ -360,11 +379,11 @@
</span><span class="cx">         return true;
</span><span class="cx">     case KeyType::Number:
</span><span class="cx">     case KeyType::Date:
</span><del>-        return m_numberValue == other.m_numberValue;
</del><ins>+        return WTF::get&lt;double&gt;(m_value) == WTF::get&lt;double&gt;(other.m_value);
</ins><span class="cx">     case KeyType::String:
</span><del>-        return m_stringValue == other.m_stringValue;
</del><ins>+        return WTF::get&lt;String&gt;(m_value) == WTF::get&lt;String&gt;(other.m_value);
</ins><span class="cx">     case KeyType::Array:
</span><del>-        return m_arrayValue == other.m_arrayValue;
</del><ins>+        return WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(m_value) == WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(other.m_value);
</ins><span class="cx">     }
</span><span class="cx">     RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBKeyDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h (208309 => 208310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h        2016-11-02 22:19:39 UTC (rev 208309)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h        2016-11-02 23:04:22 UTC (rev 208310)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(INDEXED_DATABASE)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;IDBKey.h&quot;
</span><ins>+#include &lt;wtf/Variant.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/StringHash.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -114,13 +115,13 @@
</span><span class="cx">             break;
</span><span class="cx">         case KeyType::Number:
</span><span class="cx">         case KeyType::Date:
</span><del>-            hashCodes.append(StringHasher::hashMemory&lt;sizeof(double)&gt;(&amp;m_numberValue));
</del><ins>+            hashCodes.append(StringHasher::hashMemory&lt;sizeof(double)&gt;(&amp;WTF::get&lt;double&gt;(m_value)));
</ins><span class="cx">             break;
</span><span class="cx">         case KeyType::String:
</span><del>-            hashCodes.append(StringHash::hash(m_stringValue));
</del><ins>+            hashCodes.append(StringHash::hash(WTF::get&lt;String&gt;(m_value)));
</ins><span class="cx">             break;
</span><span class="cx">         case KeyType::Array:
</span><del>-            for (auto&amp; key : m_arrayValue)
</del><ins>+            for (auto&amp; key : WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(m_value))
</ins><span class="cx">                 hashCodes.append(key.hash());
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="lines">@@ -134,25 +135,25 @@
</span><span class="cx">     String string() const
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_type == KeyType::String);
</span><del>-        return m_stringValue;
</del><ins>+        return WTF::get&lt;String&gt;(m_value);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     double date() const
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_type == KeyType::Date);
</span><del>-        return m_numberValue;
</del><ins>+        return WTF::get&lt;double&gt;(m_value);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     double number() const
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_type == KeyType::Number);
</span><del>-        return m_numberValue;
</del><ins>+        return WTF::get&lt;double&gt;(m_value);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     const Vector&lt;IDBKeyData&gt;&amp; array() const
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_type == KeyType::Array);
</span><del>-        return m_arrayValue;
</del><ins>+        return WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(m_value);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="lines">@@ -159,9 +160,8 @@
</span><span class="cx">     static void isolatedCopy(const IDBKeyData&amp; source, IDBKeyData&amp; destination);
</span><span class="cx"> 
</span><span class="cx">     KeyType m_type;
</span><del>-    Vector&lt;IDBKeyData&gt; m_arrayValue;
-    String m_stringValue;
-    double m_numberValue { 0 };
</del><ins>+    Variant&lt;Vector&lt;IDBKeyData&gt;, String, double&gt; m_value;
+
</ins><span class="cx">     bool m_isNull { false };
</span><span class="cx">     bool m_isDeletedValue { false };
</span><span class="cx"> };
</span><span class="lines">@@ -212,14 +212,14 @@
</span><span class="cx">     case KeyType::Min:
</span><span class="cx">         break;
</span><span class="cx">     case KeyType::Array:
</span><del>-        encoder &lt;&lt; m_arrayValue;
</del><ins>+        encoder &lt;&lt; WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(m_value);
</ins><span class="cx">         break;
</span><span class="cx">     case KeyType::String:
</span><del>-        encoder &lt;&lt; m_stringValue;
</del><ins>+        encoder &lt;&lt; WTF::get&lt;String&gt;(m_value);
</ins><span class="cx">         break;
</span><span class="cx">     case KeyType::Date:
</span><span class="cx">     case KeyType::Number:
</span><del>-        encoder &lt;&lt; m_numberValue;
</del><ins>+        encoder &lt;&lt; WTF::get&lt;double&gt;(m_value);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -242,16 +242,19 @@
</span><span class="cx">     case KeyType::Min:
</span><span class="cx">         break;
</span><span class="cx">     case KeyType::Array:
</span><del>-        if (!decoder.decode(keyData.m_arrayValue))
</del><ins>+        keyData.m_value = Vector&lt;IDBKeyData&gt;();
+        if (!decoder.decode(WTF::get&lt;Vector&lt;IDBKeyData&gt;&gt;(keyData.m_value)))
</ins><span class="cx">             return false;
</span><span class="cx">         break;
</span><span class="cx">     case KeyType::String:
</span><del>-        if (!decoder.decode(keyData.m_stringValue))
</del><ins>+        keyData.m_value = String();
+        if (!decoder.decode(WTF::get&lt;String&gt;(keyData.m_value)))
</ins><span class="cx">             return false;
</span><span class="cx">         break;
</span><span class="cx">     case KeyType::Date:
</span><span class="cx">     case KeyType::Number:
</span><del>-        if (!decoder.decode(keyData.m_numberValue))
</del><ins>+        keyData.m_value = 0.0;
+        if (!decoder.decode(WTF::get&lt;double&gt;(keyData.m_value)))
</ins><span class="cx">             return false;
</span><span class="cx">         break;
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>