Diff
Modified: trunk/Source/WebCore/ChangeLog (191209 => 191210)
--- trunk/Source/WebCore/ChangeLog 2015-10-16 21:10:50 UTC (rev 191209)
+++ trunk/Source/WebCore/ChangeLog 2015-10-16 21:10:58 UTC (rev 191210)
@@ -1,3 +1,42 @@
+2015-10-16 Brady Eidson <beid...@apple.com>
+
+ "enum class" some IDB enums.
+ https://bugs.webkit.org/show_bug.cgi?id=150246
+
+ Reviewed by Alex Christensen.
+
+ No new tests (No change in behavior).
+
+ * Modules/indexeddb/IDBKeyPath.cpp:
+ (WebCore::IDBIsValidKeyPath):
+ (WebCore::IDBParseKeyPath):
+ (WebCore::IDBKeyPath::IDBKeyPath):
+ (WebCore::IDBKeyPath::isValid):
+ (WebCore::IDBKeyPath::operator==):
+ (WebCore::IDBKeyPath::encode):
+ (WebCore::IDBKeyPath::decode):
+ * Modules/indexeddb/IDBKeyPath.h:
+ (WebCore::IDBKeyPath::IDBKeyPath):
+ (WebCore::IDBKeyPath::type):
+ (WebCore::IDBKeyPath::array):
+ (WebCore::IDBKeyPath::string):
+ (WebCore::IDBKeyPath::isNull):
+ (WebCore::IDBKeyPath::encode):
+ (WebCore::IDBKeyPath::decode):
+ * Modules/indexeddb/IndexedDB.h:
+ * Modules/indexeddb/legacy/LegacyDatabase.cpp:
+ (WebCore::LegacyDatabase::createObjectStore):
+ * Modules/indexeddb/legacy/LegacyObjectStore.cpp:
+ (WebCore::LegacyObjectStore::createIndex):
+ * bindings/js/IDBBindingUtilities.cpp:
+ (WebCore::internalCreateIDBKeyFromScriptValueAndKeyPath):
+ (WebCore::injectIDBKeyIntoScriptValue):
+ (WebCore::createIDBKeyFromScriptValueAndKeyPath):
+ (WebCore::canInjectIDBKeyIntoScriptValue):
+ * bindings/js/JSIDBAnyCustom.cpp:
+ (WebCore::toJS):
+ * inspector/InspectorIndexedDBAgent.cpp:
+
2015-10-16 Anders Carlsson <ander...@apple.com>
Add indexeddb/shared to the include paths.
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp (191209 => 191210)
--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp 2015-10-16 21:10:50 UTC (rev 191209)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp 2015-10-16 21:10:58 UTC (rev 191210)
@@ -125,7 +125,7 @@
IDBKeyPathParseError error;
Vector<String> keyPathElements;
IDBParseKeyPath(keyPath, keyPathElements, error);
- return error == IDBKeyPathParseErrorNone;
+ return error == IDBKeyPathParseError::None;
}
void IDBParseKeyPath(const String& keyPath, Vector<String>& elements, IDBKeyPathParseError& error)
@@ -146,7 +146,7 @@
else if (tokenType == IDBKeyPathLexer::TokenEnd)
state = End;
else {
- error = IDBKeyPathParseErrorStart;
+ error = IDBKeyPathParseError::Start;
return;
}
@@ -165,7 +165,7 @@
else if (tokenType == IDBKeyPathLexer::TokenEnd)
state = End;
else {
- error = IDBKeyPathParseErrorIdentifier;
+ error = IDBKeyPathParseError::Identifier;
return;
}
break;
@@ -178,13 +178,13 @@
if (tokenType == IDBKeyPathLexer::TokenIdentifier)
state = Identifier;
else {
- error = IDBKeyPathParseErrorDot;
+ error = IDBKeyPathParseError::Dot;
return;
}
break;
}
case End: {
- error = IDBKeyPathParseErrorNone;
+ error = IDBKeyPathParseError::None;
return;
}
}
@@ -192,14 +192,14 @@
}
IDBKeyPath::IDBKeyPath(const String& string)
- : m_type(StringType)
+ : m_type(IndexedDB::KeyPathType::String)
, m_string(string)
{
ASSERT(!m_string.isNull());
}
IDBKeyPath::IDBKeyPath(const Vector<String>& array)
- : m_type(ArrayType)
+ : m_type(IndexedDB::KeyPathType::Array)
, m_array(array)
{
#ifndef NDEBUG
@@ -211,13 +211,13 @@
bool IDBKeyPath::isValid() const
{
switch (m_type) {
- case NullType:
+ case IndexedDB::KeyPathType::Null:
return false;
- case StringType:
+ case IndexedDB::KeyPathType::String:
return IDBIsValidKeyPath(m_string);
- case ArrayType:
+ case IndexedDB::KeyPathType::Array:
if (m_array.isEmpty())
return false;
for (auto& key : m_array) {
@@ -236,11 +236,11 @@
return false;
switch (m_type) {
- case NullType:
+ case IndexedDB::KeyPathType::Null:
return true;
- case StringType:
+ case IndexedDB::KeyPathType::String:
return m_string == other.m_string;
- case ArrayType:
+ case IndexedDB::KeyPathType::Array:
return m_array == other.m_array;
}
ASSERT_NOT_REACHED();
@@ -264,12 +264,12 @@
{
encoder.encodeEnum("type", m_type);
switch (m_type) {
- case IDBKeyPath::NullType:
+ case IndexedDB::KeyPathType::Null:
break;
- case IDBKeyPath::StringType:
+ case IndexedDB::KeyPathType::String:
encoder.encodeString("string", m_string);
break;
- case IDBKeyPath::ArrayType:
+ case IndexedDB::KeyPathType::Array:
encoder.encodeObjects("array", m_array.begin(), m_array.end(), [](WebCore::KeyedEncoder& encoder, const String& string) {
encoder.encodeString("string", string);
});
@@ -281,20 +281,20 @@
bool IDBKeyPath::decode(KeyedDecoder& decoder, IDBKeyPath& result)
{
- auto enumFunction = [](int64_t value) {
- return value == NullType || value == StringType || value == ArrayType;
+ auto enumFunction = [](IndexedDB::KeyPathType value) {
+ return value == IndexedDB::KeyPathType::Null || value == IndexedDB::KeyPathType::String || value == IndexedDB::KeyPathType::Array;
};
if (!decoder.decodeEnum("type", result.m_type, enumFunction))
return false;
- if (result.m_type == NullType)
+ if (result.m_type == IndexedDB::KeyPathType::Null)
return true;
- if (result.m_type == StringType)
+ if (result.m_type == IndexedDB::KeyPathType::String)
return decoder.decodeString("string", result.m_string);
- ASSERT(result.m_type == ArrayType);
+ ASSERT(result.m_type == IndexedDB::KeyPathType::Array);
auto arrayFunction = [](KeyedDecoder& decoder, String& result) {
return decoder.decodeString("string", result);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.h (191209 => 191210)
--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.h 2015-10-16 21:10:50 UTC (rev 191209)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.h 2015-10-16 21:10:58 UTC (rev 191210)
@@ -28,6 +28,7 @@
#if ENABLE(INDEXED_DATABASE)
+#include "IndexedDB.h"
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
@@ -36,42 +37,36 @@
class KeyedDecoder;
class KeyedEncoder;
-enum IDBKeyPathParseError {
- IDBKeyPathParseErrorNone,
- IDBKeyPathParseErrorStart,
- IDBKeyPathParseErrorIdentifier,
- IDBKeyPathParseErrorDot,
+enum class IDBKeyPathParseError {
+ None,
+ Start,
+ Identifier,
+ Dot,
};
void IDBParseKeyPath(const String&, Vector<String>&, IDBKeyPathParseError&);
class IDBKeyPath {
public:
- IDBKeyPath() : m_type(NullType) { }
+ IDBKeyPath() { }
WEBCORE_EXPORT explicit IDBKeyPath(const String&);
WEBCORE_EXPORT explicit IDBKeyPath(const Vector<String>& array);
- enum Type {
- NullType = 0,
- StringType,
- ArrayType
- };
+ IndexedDB::KeyPathType type() const { return m_type; }
- Type type() const { return m_type; }
-
const Vector<String>& array() const
{
- ASSERT(m_type == ArrayType);
+ ASSERT(m_type == IndexedDB::KeyPathType::Array);
return m_array;
}
const String& string() const
{
- ASSERT(m_type == StringType);
+ ASSERT(m_type == IndexedDB::KeyPathType::String);
return m_string;
}
- bool isNull() const { return m_type == NullType; }
+ bool isNull() const { return m_type == IndexedDB::KeyPathType::Null; }
bool isValid() const;
bool operator==(const IDBKeyPath& other) const;
@@ -84,7 +79,7 @@
WEBCORE_EXPORT static bool decode(KeyedDecoder&, IDBKeyPath&);
private:
- Type m_type;
+ IndexedDB::KeyPathType m_type { IndexedDB::KeyPathType::Null };
String m_string;
Vector<String> m_array;
};
@@ -95,12 +90,12 @@
encoder.encodeEnum(m_type);
switch (m_type) {
- case IDBKeyPath::NullType:
+ case IndexedDB::KeyPathType::Null:
break;
- case IDBKeyPath::StringType:
+ case IndexedDB::KeyPathType::String:
encoder << m_string;
break;
- case IDBKeyPath::ArrayType:
+ case IndexedDB::KeyPathType::Array:
encoder << m_array;
break;
default:
@@ -111,16 +106,16 @@
template<class Decoder>
bool IDBKeyPath::decode(Decoder& decoder, IDBKeyPath& keyPath)
{
- IDBKeyPath::Type type;
+ IndexedDB::KeyPathType type;
if (!decoder.decodeEnum(type))
return false;
switch (type) {
- case IDBKeyPath::NullType:
+ case IndexedDB::KeyPathType::Null:
keyPath = IDBKeyPath();
return true;
- case IDBKeyPath::StringType: {
+ case IndexedDB::KeyPathType::String: {
String string;
if (!decoder.decode(string))
return false;
@@ -128,7 +123,7 @@
keyPath = IDBKeyPath(string);
return true;
}
- case IDBKeyPath::ArrayType: {
+ case IndexedDB::KeyPathType::Array: {
Vector<String> array;
if (!decoder.decode(array))
return false;
Modified: trunk/Source/WebCore/Modules/indexeddb/IndexedDB.h (191209 => 191210)
--- trunk/Source/WebCore/Modules/indexeddb/IndexedDB.h 2015-10-16 21:10:50 UTC (rev 191209)
+++ trunk/Source/WebCore/Modules/indexeddb/IndexedDB.h 2015-10-16 21:10:58 UTC (rev 191210)
@@ -64,6 +64,12 @@
Null,
NonNull,
};
+
+enum class KeyPathType {
+ Null,
+ String,
+ Array,
+};
// In order of the least to the highest precedent in terms of sort order.
enum KeyType {
Modified: trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyDatabase.cpp (191209 => 191210)
--- trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyDatabase.cpp 2015-10-16 21:10:50 UTC (rev 191209)
+++ trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyDatabase.cpp 2015-10-16 21:10:58 UTC (rev 191210)
@@ -201,7 +201,7 @@
return 0;
}
- if (autoIncrement && ((keyPath.type() == IDBKeyPath::StringType && keyPath.string().isEmpty()) || keyPath.type() == IDBKeyPath::ArrayType)) {
+ if (autoIncrement && ((keyPath.type() == IndexedDB::KeyPathType::String && keyPath.string().isEmpty()) || keyPath.type() == IndexedDB::KeyPathType::Array)) {
ec = IDBDatabaseException::InvalidAccessError;
return 0;
}
Modified: trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.cpp (191209 => 191210)
--- trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.cpp 2015-10-16 21:10:50 UTC (rev 191209)
+++ trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.cpp 2015-10-16 21:10:58 UTC (rev 191210)
@@ -385,7 +385,7 @@
return 0;
}
- if (keyPath.type() == IDBKeyPath::ArrayType && multiEntry) {
+ if (keyPath.type() == IndexedDB::KeyPathType::Array && multiEntry) {
ec = IDBDatabaseException::InvalidAccessError;
return 0;
}
Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp (191209 => 191210)
--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp 2015-10-16 21:10:50 UTC (rev 191209)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp 2015-10-16 21:10:58 UTC (rev 191210)
@@ -187,7 +187,7 @@
Vector<String> keyPathElements;
IDBKeyPathParseError error;
IDBParseKeyPath(keyPath, keyPathElements, error);
- ASSERT(error == IDBKeyPathParseErrorNone);
+ ASSERT(error == IDBKeyPathParseError::None);
JSValue jsValue = value.jsValue();
jsValue = getNthValueOnKeyPath(exec, jsValue, keyPathElements, keyPathElements.size());
@@ -236,12 +236,12 @@
{
LOG(StorageAPI, "injectIDBKeyIntoScriptValue");
- ASSERT(keyPath.type() == IDBKeyPath::StringType);
+ ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
Vector<String> keyPathElements;
IDBKeyPathParseError error;
IDBParseKeyPath(keyPath.string(), keyPathElements, error);
- ASSERT(error == IDBKeyPathParseErrorNone);
+ ASSERT(error == IDBKeyPathParseError::None);
if (keyPathElements.isEmpty())
return false;
@@ -263,7 +263,7 @@
LOG(StorageAPI, "createIDBKeyFromScriptValueAndKeyPath");
ASSERT(!keyPath.isNull());
- if (keyPath.type() == IDBKeyPath::ArrayType) {
+ if (keyPath.type() == IndexedDB::KeyPathType::Array) {
Vector<RefPtr<IDBKey>> result;
const Vector<String>& array = keyPath.array();
for (size_t i = 0; i < array.size(); i++) {
@@ -275,7 +275,7 @@
return IDBKey::createArray(result);
}
- ASSERT(keyPath.type() == IDBKeyPath::StringType);
+ ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
return internalCreateIDBKeyFromScriptValueAndKeyPath(exec, value, keyPath.string());
}
@@ -283,11 +283,11 @@
{
LOG(StorageAPI, "canInjectIDBKeyIntoScriptValue");
- ASSERT(keyPath.type() == IDBKeyPath::StringType);
+ ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
Vector<String> keyPathElements;
IDBKeyPathParseError error;
IDBParseKeyPath(keyPath.string(), keyPathElements, error);
- ASSERT(error == IDBKeyPathParseErrorNone);
+ ASSERT(error == IDBKeyPathParseError::None);
if (!keyPathElements.size())
return false;
Modified: trunk/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp (191209 => 191210)
--- trunk/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp 2015-10-16 21:10:50 UTC (rev 191209)
+++ trunk/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp 2015-10-16 21:10:58 UTC (rev 191210)
@@ -56,11 +56,11 @@
static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const IDBKeyPath& value)
{
switch (value.type()) {
- case IDBKeyPath::NullType:
+ case IndexedDB::KeyPathType::Null:
return jsNull();
- case IDBKeyPath::StringType:
+ case IndexedDB::KeyPathType::String:
return jsStringWithCache(exec, value.string());
- case IDBKeyPath::ArrayType:
+ case IndexedDB::KeyPathType::Array:
RefPtr<DOMStringList> keyPaths = DOMStringList::create();
for (Vector<String>::const_iterator it = value.array().begin(); it != value.array().end(); ++it)
keyPaths->append(*it);
Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (191209 => 191210)
--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2015-10-16 21:10:50 UTC (rev 191209)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2015-10-16 21:10:58 UTC (rev 191210)
@@ -250,19 +250,19 @@
{
RefPtr<KeyPath> keyPath;
switch (idbKeyPath.type()) {
- case IDBKeyPath::NullType:
+ case IndexedDB::KeyPathType::Null:
keyPath = KeyPath::create()
.setType(KeyPath::Type::Null)
.release();
break;
- case IDBKeyPath::StringType:
+ case IndexedDB::KeyPathType::String:
keyPath = KeyPath::create()
.setType(KeyPath::Type::String)
.release();
keyPath->setString(idbKeyPath.string());
break;
- case IDBKeyPath::ArrayType: {
+ case IndexedDB::KeyPathType::Array: {
auto array = Inspector::Protocol::Array<String>::create();
for (auto& string : idbKeyPath.array())
array->addItem(string);