<!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 <beidson@apple.com>
+
+ 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 <sam@webkit.org>
</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<RefPtr<IDBKey>>;
+
+IDBKey::IDBKey(KeyType type, double number)
+ : m_type(type)
+ , m_value(number)
+ , m_sizeEstimate(OverheadSize + sizeof(double))
+{
+}
+
+IDBKey::IDBKey(const String& value)
+ : m_type(KeyType::String)
+ , m_value(value)
+ , m_sizeEstimate(OverheadSize + value.length() * sizeof(UChar))
+{
+}
+
+IDBKey::IDBKey(const IDBKeyVector& 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& key : m_array) {
</del><ins>+ for (auto& key : WTF::get<IDBKeyVector>(m_value)) {
</ins><span class="cx"> if (!key->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 > 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 < m_array.size() && i < other.m_array.size(); ++i) {
- if (int result = m_array[i]->compare(*other.m_array[i]))
</del><ins>+ case KeyType::Array: {
+ auto& array = WTF::get<IDBKeyVector>(m_value);
+ auto& otherArray = WTF::get<IDBKeyVector>(other.m_value);
+ for (size_t i = 0; i < array.size() && i < 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_array.size() < other.m_array.size())
</del><ins>+ if (array.size() < otherArray.size())
</ins><span class="cx"> return -1;
</span><del>- if (m_array.size() > other.m_array.size())
</del><ins>+ if (array.size() > 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<String>(other.m_value), WTF::get<String>(m_value));
</ins><span class="cx"> case KeyType::Date:
</span><del>- case KeyType::Number:
- return (m_number < other.m_number) ? -1 : ((m_number > other. m_number) ? 1 : 0);
</del><ins>+ case KeyType::Number: {
+ auto number = WTF::get<double>(m_value);
+ auto otherNumber = WTF::get<double>(other.m_value);
+ return (number < otherNumber) ? -1 : ((number > 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 "IndexedDB.h"
</span><span class="cx"> #include <wtf/Forward.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><ins>+#include <wtf/Variant.h>
</ins><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="cx">
</span><span class="lines">@@ -103,25 +104,25 @@
</span><span class="cx"> const Vector<RefPtr<IDBKey>>& 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<Vector<RefPtr<IDBKey>>>(m_value);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> const String& 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<String>(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<double>(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<double>(m_value);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int compare(const IDBKey& 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& value) : m_type(KeyType::String), m_string(value), m_number(0), m_sizeEstimate(OverheadSize + value.length() * sizeof(UChar)) { }
- IDBKey(const Vector<RefPtr<IDBKey>>& 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& value);
+ IDBKey(const Vector<RefPtr<IDBKey>>& keyArray, size_t arraySize);
+
</ins><span class="cx"> const KeyType m_type;
</span><del>- const Vector<RefPtr<IDBKey>> m_array;
- const String m_string;
- const double m_number;
</del><ins>+ Variant<Vector<RefPtr<IDBKey>>, String, double> 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<IDBKeyData>();
+ auto& array = WTF::get<Vector<IDBKeyData>>(m_value);
</ins><span class="cx"> for (auto& key2 : key->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->string();
</del><ins>+ m_value = key->string();
</ins><span class="cx"> break;
</span><span class="cx"> case KeyType::Date:
</span><del>- m_numberValue = key->date();
</del><ins>+ m_value = key->date();
</ins><span class="cx"> break;
</span><span class="cx"> case KeyType::Number:
</span><del>- m_numberValue = key->number();
</del><ins>+ m_value = key->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<RefPtr<IDBKey>> array;
- for (auto& keyData : m_arrayValue) {
- array.append(keyData.maybeCreateIDBKey());
- ASSERT(array.last());
- }
- return IDBKey::createArray(array);
</del><ins>+ case KeyType::Array: {
+ Vector<RefPtr<IDBKey>> array;
+ for (auto& keyData : WTF::get<Vector<IDBKeyData>>(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<String>(m_value));
</ins><span class="cx"> case KeyType::Date:
</span><del>- return IDBKey::createDate(m_numberValue);
</del><ins>+ return IDBKey::createDate(WTF::get<double>(m_value));
</ins><span class="cx"> case KeyType::Number:
</span><del>- return IDBKey::createNumber(m_numberValue);
</del><ins>+ return IDBKey::createNumber(WTF::get<double>(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& key : source.m_arrayValue)
- destination.m_arrayValue.append(key.isolatedCopy());
</del><ins>+ case KeyType::Array: {
+ destination.m_value = Vector<IDBKeyData>();
+ auto& destinationArray = WTF::get<Vector<IDBKeyData>>(destination.m_value);
+ for (auto& key : WTF::get<Vector<IDBKeyData>>(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<String>(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<double>(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("array", m_arrayValue.begin(), m_arrayValue.end(), [](KeyedEncoder& encoder, const IDBKeyData& key) {
</del><ins>+ case KeyType::Array: {
+ auto& array = WTF::get<Vector<IDBKeyData>>(m_value);
+ encoder.encodeObjects("array", array.begin(), array.end(), [](KeyedEncoder& encoder, const IDBKeyData& 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("string", m_stringValue);
</del><ins>+ encoder.encodeString("string", WTF::get<String>(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("number", m_numberValue);
</del><ins>+ encoder.encodeDouble("number", WTF::get<double>(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("string", result.m_stringValue);
</del><ins>+ if (result.m_type == KeyType::String) {
+ result.m_value = String();
+ return decoder.decodeString("string", WTF::get<String>(result.m_value));
+ }
</ins><span class="cx">
</span><del>- if (result.m_type == KeyType::Number || result.m_type == KeyType::Date)
- return decoder.decodeDouble("number", result.m_numberValue);
</del><ins>+ if (result.m_type == KeyType::Number || result.m_type == KeyType::Date) {
+ result.m_value = 0.0;
+ return decoder.decodeDouble("number", WTF::get<double>(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("array", result.m_arrayValue, arrayFunction);
</del><ins>+ result.m_value = Vector<IDBKeyData>();
+ return decoder.decodeObjects("array", WTF::get<Vector<IDBKeyData>>(result.m_value), arrayFunction);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int IDBKeyData::compare(const IDBKeyData& 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 < m_arrayValue.size() && i < other.m_arrayValue.size(); ++i) {
- if (int result = m_arrayValue[i].compare(other.m_arrayValue[i]))
</del><ins>+ case KeyType::Array: {
+ auto& array = WTF::get<Vector<IDBKeyData>>(m_value);
+ auto& otherArray = WTF::get<Vector<IDBKeyData>>(other.m_value);
+ for (size_t i = 0; i < array.size() && i < 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() < other.m_arrayValue.size())
</del><ins>+ if (array.size() < otherArray.size())
</ins><span class="cx"> return -1;
</span><del>- if (m_arrayValue.size() > other.m_arrayValue.size())
</del><ins>+ if (array.size() > 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<String>(m_value), WTF::get<String>(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<double>(m_value);
+ auto otherNumber = WTF::get<double>(other.m_value);
+
+ if (number == otherNumber)
</ins><span class="cx"> return 0;
</span><del>- return m_numberValue > other.m_numberValue ? 1 : -1;
</del><ins>+ return number > 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("<array> - { ");
</span><del>- for (size_t i = 0; i < m_arrayValue.size(); ++i) {
- builder.append(m_arrayValue[i].loggingString());
- if (i < m_arrayValue.size() - 1)
</del><ins>+ auto& array = WTF::get<Vector<IDBKeyData>>(m_value);
+ for (size_t i = 0; i < array.size(); ++i) {
+ builder.append(array[i].loggingString());
+ if (i < array.size() - 1)
</ins><span class="cx"> builder.appendLiteral(", ");
</span><span class="cx"> }
</span><span class="cx"> builder.appendLiteral(" }");
</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 = "<string> - " + m_stringValue;
</del><ins>+ result = "<string> - " + WTF::get<String>(m_value);
</ins><span class="cx"> break;
</span><span class="cx"> case KeyType::Date:
</span><del>- return String::format("<date> - %f", m_numberValue);
</del><ins>+ return String::format("<date> - %f", WTF::get<double>(m_value));
</ins><span class="cx"> case KeyType::Number:
</span><del>- return String::format("<number> - %f", m_numberValue);
</del><ins>+ return String::format("<number> - %f", WTF::get<double>(m_value));
</ins><span class="cx"> case KeyType::Max:
</span><span class="cx"> return "<maximum>";
</span><span class="cx"> case KeyType::Min:
</span><span class="lines">@@ -307,7 +326,7 @@
</span><span class="cx"> void IDBKeyData::setArrayValue(const Vector<IDBKeyData>& 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& 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<double>(m_value) == WTF::get<double>(other.m_value);
</ins><span class="cx"> case KeyType::String:
</span><del>- return m_stringValue == other.m_stringValue;
</del><ins>+ return WTF::get<String>(m_value) == WTF::get<String>(other.m_value);
</ins><span class="cx"> case KeyType::Array:
</span><del>- return m_arrayValue == other.m_arrayValue;
</del><ins>+ return WTF::get<Vector<IDBKeyData>>(m_value) == WTF::get<Vector<IDBKeyData>>(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 "IDBKey.h"
</span><ins>+#include <wtf/Variant.h>
</ins><span class="cx"> #include <wtf/text/StringHash.h>
</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<sizeof(double)>(&m_numberValue));
</del><ins>+ hashCodes.append(StringHasher::hashMemory<sizeof(double)>(&WTF::get<double>(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<String>(m_value)));
</ins><span class="cx"> break;
</span><span class="cx"> case KeyType::Array:
</span><del>- for (auto& key : m_arrayValue)
</del><ins>+ for (auto& key : WTF::get<Vector<IDBKeyData>>(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<String>(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<double>(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<double>(m_value);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> const Vector<IDBKeyData>& 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<Vector<IDBKeyData>>(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& source, IDBKeyData& destination);
</span><span class="cx">
</span><span class="cx"> KeyType m_type;
</span><del>- Vector<IDBKeyData> m_arrayValue;
- String m_stringValue;
- double m_numberValue { 0 };
</del><ins>+ Variant<Vector<IDBKeyData>, String, double> 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 << m_arrayValue;
</del><ins>+ encoder << WTF::get<Vector<IDBKeyData>>(m_value);
</ins><span class="cx"> break;
</span><span class="cx"> case KeyType::String:
</span><del>- encoder << m_stringValue;
</del><ins>+ encoder << WTF::get<String>(m_value);
</ins><span class="cx"> break;
</span><span class="cx"> case KeyType::Date:
</span><span class="cx"> case KeyType::Number:
</span><del>- encoder << m_numberValue;
</del><ins>+ encoder << WTF::get<double>(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<IDBKeyData>();
+ if (!decoder.decode(WTF::get<Vector<IDBKeyData>>(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<String>(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<double>(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>