Title: [210275] trunk/Source/WebCore
Revision
210275
Author
wei...@apple.com
Date
2017-01-04 09:48:58 -0800 (Wed, 04 Jan 2017)

Log Message

Remove final custom binding from IDBRequest
https://bugs.webkit.org/show_bug.cgi?id=166671

Reviewed by Alex Christensen.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
Remove JSIDBRequestCustom.cpp

* bindings/js/JSIDBRequestCustom.cpp: Removed.

* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::IDBRequest):
(WebCore::IDBRequest::~IDBRequest):
(WebCore::IDBRequest::result):
(WebCore::IDBRequest::setSource):
(WebCore::IDBRequest::sourceObjectStoreIdentifier):
(WebCore::IDBRequest::sourceIndexIdentifier):
(WebCore::IDBRequest::requestedIndexRecordType):
(WebCore::IDBRequest::setResult):
(WebCore::IDBRequest::setResultToStructuredClone):
(WebCore::IDBRequest::setResultToUndefined):
(WebCore::IDBRequest::resultCursor):
(WebCore::IDBRequest::willIterateCursor):
(WebCore::IDBRequest::didOpenOrIterateCursor):
(WebCore::IDBRequest::source): Deleted.
(WebCore::IDBRequest::clearResult): Deleted.
* Modules/indexeddb/IDBRequest.h:
(WebCore::IDBRequest::source):
(WebCore::IDBRequest::cursorResult): Deleted.
(WebCore::IDBRequest::databaseResult): Deleted.
(WebCore::IDBRequest::scriptResult): Deleted.
Replace multiple member variables with Variants for source and result. Add a result
member function that properly sets an exception if not "done".

* Modules/indexeddb/IDBRequest.idl:
Remove CustomGetter annotation and add type.

* bindings/generic/IDLTypes.h:
(WebCore::IDLAny::nullValue):
(WebCore::IDLAny::isNullValue):
(WebCore::IDLAny::extractValueFromNullable):
* bindings/js/JSDOMConvert.h:
(WebCore::Converter<IDLAny>::convert):
Flesh out IDLAny to be implemented as a Strong<Unknown> when used in aggregate types,
but still work with JSValue when passing as a parameter.

* inspector/InspectorIndexedDBAgent.cpp:
Update for new return value of IDBRequest::result().

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (210274 => 210275)


--- trunk/Source/WebCore/CMakeLists.txt	2017-01-04 13:59:44 UTC (rev 210274)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-01-04 17:48:58 UTC (rev 210275)
@@ -1148,7 +1148,6 @@
     bindings/js/JSIDBCursorWithValueCustom.cpp
     bindings/js/JSIDBIndexCustom.cpp
     bindings/js/JSIDBObjectStoreCustom.cpp
-    bindings/js/JSIDBRequestCustom.cpp
     bindings/js/JSIDBTransactionCustom.cpp
     bindings/js/JSImageDataCustom.cpp
     bindings/js/JSInspectorFrontendHostCustom.cpp

Modified: trunk/Source/WebCore/ChangeLog (210274 => 210275)


--- trunk/Source/WebCore/ChangeLog	2017-01-04 13:59:44 UTC (rev 210274)
+++ trunk/Source/WebCore/ChangeLog	2017-01-04 17:48:58 UTC (rev 210275)
@@ -1,3 +1,55 @@
+2017-01-03  Sam Weinig  <s...@webkit.org>
+
+        Remove final custom binding from IDBRequest
+        https://bugs.webkit.org/show_bug.cgi?id=166671
+
+        Reviewed by Alex Christensen.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        Remove JSIDBRequestCustom.cpp
+
+        * bindings/js/JSIDBRequestCustom.cpp: Removed.
+
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::IDBRequest):
+        (WebCore::IDBRequest::~IDBRequest):
+        (WebCore::IDBRequest::result):
+        (WebCore::IDBRequest::setSource):
+        (WebCore::IDBRequest::sourceObjectStoreIdentifier):
+        (WebCore::IDBRequest::sourceIndexIdentifier):
+        (WebCore::IDBRequest::requestedIndexRecordType):
+        (WebCore::IDBRequest::setResult):
+        (WebCore::IDBRequest::setResultToStructuredClone):
+        (WebCore::IDBRequest::setResultToUndefined):
+        (WebCore::IDBRequest::resultCursor):
+        (WebCore::IDBRequest::willIterateCursor):
+        (WebCore::IDBRequest::didOpenOrIterateCursor):
+        (WebCore::IDBRequest::source): Deleted.
+        (WebCore::IDBRequest::clearResult): Deleted.
+        * Modules/indexeddb/IDBRequest.h:
+        (WebCore::IDBRequest::source):
+        (WebCore::IDBRequest::cursorResult): Deleted.
+        (WebCore::IDBRequest::databaseResult): Deleted.
+        (WebCore::IDBRequest::scriptResult): Deleted.
+        Replace multiple member variables with Variants for source and result. Add a result
+        member function that properly sets an exception if not "done".
+
+        * Modules/indexeddb/IDBRequest.idl:
+        Remove CustomGetter annotation and add type.
+
+        * bindings/generic/IDLTypes.h:
+        (WebCore::IDLAny::nullValue):
+        (WebCore::IDLAny::isNullValue):
+        (WebCore::IDLAny::extractValueFromNullable):
+        * bindings/js/JSDOMConvert.h:
+        (WebCore::Converter<IDLAny>::convert):
+        Flesh out IDLAny to be implemented as a Strong<Unknown> when used in aggregate types,
+        but still work with JSValue when passing as a parameter.
+
+        * inspector/InspectorIndexedDBAgent.cpp:
+        Update for new return value of IDBRequest::result().
+
 2017-01-04  Tim Horton  <timothy_hor...@apple.com>
 
         Provide a setting for clients to always prefer low-power WebGL

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp (210274 => 210275)


--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp	2017-01-04 13:59:44 UTC (rev 210274)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp	2017-01-04 17:48:58 UTC (rev 210275)
@@ -91,7 +91,7 @@
     : IDBActiveDOMObject(&context)
     , m_transaction(&transaction)
     , m_resourceIdentifier(transaction.connectionProxy())
-    , m_objectStoreSource(&objectStore)
+    , m_source(&objectStore)
     , m_connectionProxy(transaction.database().connectionProxy())
 {
     suspendIfNeeded();
@@ -107,8 +107,7 @@
     suspendIfNeeded();
 
     WTF::switchOn(cursor.source(),
-        [this] (const RefPtr<IDBIndex>& index) { this->m_indexSource = index; },
-        [this] (const RefPtr<IDBObjectStore>& objectStore) { this->m_objectStoreSource = objectStore; }
+        [this] (const auto& value) { this->m_source = IDBRequest::Source { value }; }
     );
 
     cursor.setRequest(*this);
@@ -118,7 +117,7 @@
     : IDBActiveDOMObject(&context)
     , m_transaction(&transaction)
     , m_resourceIdentifier(transaction.connectionProxy())
-    , m_indexSource(&index)
+    , m_source(&index)
     , m_connectionProxy(transaction.database().connectionProxy())
 {
     suspendIfNeeded();
@@ -128,7 +127,7 @@
     : IDBActiveDOMObject(&context)
     , m_transaction(&transaction)
     , m_resourceIdentifier(transaction.connectionProxy())
-    , m_objectStoreSource(&objectStore)
+    , m_source(&objectStore)
     , m_requestedObjectStoreRecordType(type)
     , m_connectionProxy(transaction.database().connectionProxy())
 {
@@ -145,10 +144,22 @@
 {
     ASSERT(currentThread() == originThreadID());
 
-    if (m_cursorResult)
-        m_cursorResult->clearRequest();
+    if (m_result) {
+        WTF::switchOn(m_result.value(),
+            [] (RefPtr<IDBCursor>& cursor) { cursor->clearRequest(); },
+            [] (const auto&) { }
+        );
+    }
 }
 
+ExceptionOr<std::optional<IDBRequest::Result>> IDBRequest::result() const
+{
+    if (!isDone())
+        return Exception { IDBDatabaseException::InvalidStateError, ASCIILiteral("Failed to read the 'result' property from 'IDBRequest': The request has not finished.") };
+
+    return std::optional<IDBRequest::Result> { m_result };
+}
+
 ExceptionOr<DOMError*> IDBRequest::error() const
 {
     ASSERT(currentThread() == originThreadID());
@@ -159,29 +170,15 @@
     return m_domError.get();
 }
 
-std::optional<IDBRequest::Source> IDBRequest::source() const
-{
-    if (m_cursorSource)
-        return Source { m_cursorSource };
-    if (m_indexSource)
-        return Source { m_indexSource };
-    if (m_objectStoreSource)
-        return Source { m_objectStoreSource };
-
-    return std::nullopt;
-}
-
 void IDBRequest::setSource(IDBCursor& cursor)
 {
     ASSERT(currentThread() == originThreadID());
     ASSERT(!m_cursorRequestNotifier);
 
-    m_objectStoreSource = nullptr;
-    m_indexSource = nullptr;
-    m_cursorSource = &cursor;
+    m_source = Source { &cursor };
     m_cursorRequestNotifier = std::make_unique<ScopeGuard>([this]() {
-        ASSERT(m_cursorSource);
-        m_cursorSource->decrementOutstandingRequestCount();
+        ASSERT(WTF::holds_alternative<RefPtr<IDBCursor>>(m_source.value()));
+        WTF::get<RefPtr<IDBCursor>>(m_source.value())->decrementOutstandingRequestCount();
     });
 }
 
@@ -205,11 +202,14 @@
 {
     ASSERT(currentThread() == originThreadID());
 
-    if (m_objectStoreSource)
-        return m_objectStoreSource->info().identifier();
-    if (m_indexSource)
-        return m_indexSource->info().objectStoreIdentifier();
-    return 0;
+    if (!m_source)
+        return 0;
+
+    return WTF::switchOn(m_source.value(),
+        [] (const RefPtr<IDBObjectStore>& objectStore) { return objectStore->info().identifier(); },
+        [] (const RefPtr<IDBIndex>& index) { return index->info().objectStoreIdentifier(); },
+        [] (const RefPtr<IDBCursor>&) { return 0; }
+    );
 }
 
 uint64_t IDBRequest::sourceIndexIdentifier() const
@@ -216,9 +216,14 @@
 {
     ASSERT(currentThread() == originThreadID());
 
-    if (!m_indexSource)
+    if (!m_source)
         return 0;
-    return m_indexSource->info().identifier();
+
+    return WTF::switchOn(m_source.value(),
+        [] (const RefPtr<IDBObjectStore>&) -> uint64_t { return 0; },
+        [] (const RefPtr<IDBIndex>& index) -> uint64_t { return index->info().identifier(); },
+        [] (const RefPtr<IDBCursor>&) -> uint64_t { return 0; }
+    );
 }
 
 IndexedDB::ObjectStoreRecordType IDBRequest::requestedObjectStoreRecordType() const
@@ -231,7 +236,8 @@
 IndexedDB::IndexRecordType IDBRequest::requestedIndexRecordType() const
 {
     ASSERT(currentThread() == originThreadID());
-    ASSERT(m_indexSource);
+    ASSERT(m_source);
+    ASSERT(WTF::holds_alternative<RefPtr<IDBIndex>>(m_source.value()));
 
     return m_requestedIndexRecordType;
 }
@@ -362,8 +368,7 @@
     if (!exec)
         return;
 
-    clearResult();
-    m_scriptResult = { context->vm(), idbKeyDataToScriptValue(*exec, keyData) };
+    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), idbKeyDataToScriptValue(*exec, keyData) } };
 }
 
 void IDBRequest::setResult(const Vector<IDBKeyData>& keyDatas)
@@ -378,10 +383,9 @@
     if (!state)
         return;
 
-    clearResult();
 
     Locker<JSLock> locker(context->vm().apiLock());
-    m_scriptResult = { context->vm(), toJS(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), keyDatas) };
+    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), toJS(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), keyDatas) } };
 }
 
 void IDBRequest::setResult(const Vector<IDBValue>& values)
@@ -396,10 +400,8 @@
     if (!exec)
         return;
 
-    clearResult();
-
     Locker<JSLock> locker(context->vm().apiLock());
-    m_scriptResult = { context->vm(), toJS(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), values) };
+    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), toJS(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), values) } };
 }
 
 void IDBRequest::setResult(uint64_t number)
@@ -410,8 +412,7 @@
     if (!context)
         return;
 
-    clearResult();
-    m_scriptResult = { context->vm(), JSC::jsNumber(number) };
+    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), JSC::jsNumber(number) } };
 }
 
 void IDBRequest::setResultToStructuredClone(const IDBValue& value)
@@ -428,19 +429,9 @@
     if (!exec)
         return;
 
-    clearResult();
-    m_scriptResult = { context->vm(), deserializeIDBValueToJSValue(*exec, value) };
+    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), deserializeIDBValueToJSValue(*exec, value) } };
 }
 
-void IDBRequest::clearResult()
-{
-    ASSERT(currentThread() == originThreadID());
-
-    m_scriptResult = { };
-    m_cursorResult = nullptr;
-    m_databaseResult = nullptr;
-}
-
 void IDBRequest::setResultToUndefined()
 {
     ASSERT(currentThread() == originThreadID());
@@ -449,8 +440,7 @@
     if (!context)
         return;
 
-    clearResult();
-    m_scriptResult = { context->vm(), JSC::jsUndefined() };
+    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), JSC::jsUndefined() } };
 }
 
 IDBCursor* IDBRequest::resultCursor()
@@ -457,7 +447,13 @@
 {
     ASSERT(currentThread() == originThreadID());
 
-    return m_cursorResult.get();
+    if (!m_result)
+        return nullptr;
+
+    return WTF::switchOn(m_result.value(),
+        [] (const RefPtr<IDBCursor>& cursor) -> IDBCursor* { return cursor.get(); },
+        [] (const auto&) -> IDBCursor* { return nullptr; }
+    );
 }
 
 void IDBRequest::willIterateCursor(IDBCursor& cursor)
@@ -472,7 +468,7 @@
 
     m_pendingCursor = &cursor;
     m_hasPendingActivity = true;
-    clearResult();
+    m_result = std::nullopt;
     m_readyState = ReadyState::Pending;
     m_domError = nullptr;
     m_idbError = { };
@@ -487,12 +483,12 @@
     ASSERT(currentThread() == originThreadID());
     ASSERT(m_pendingCursor);
 
-    clearResult();
+    m_result = std::nullopt;
 
     if (resultData.type() == IDBResultType::IterateCursorSuccess || resultData.type() == IDBResultType::OpenCursorSuccess) {
         m_pendingCursor->setGetResult(*this, resultData.getResult());
         if (resultData.getResult().isDefined())
-            m_cursorResult = m_pendingCursor;
+            m_result = Result { m_pendingCursor };
     }
 
     m_cursorRequestNotifier = nullptr;
@@ -537,8 +533,7 @@
 {
     ASSERT(currentThread() == originThreadID());
 
-    clearResult();
-    m_databaseResult = WTFMove(database);
+    m_result = Result { RefPtr<IDBDatabase> { WTFMove(database) } };
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h (210274 => 210275)


--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h	2017-01-04 13:59:44 UTC (rev 210274)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h	2017-01-04 17:48:58 UTC (rev 210275)
@@ -67,12 +67,11 @@
 
     virtual ~IDBRequest();
 
-    IDBCursor* cursorResult() const { return m_cursorResult.get(); }
-    IDBDatabase* databaseResult() const { return m_databaseResult.get(); }
-    JSC::JSValue scriptResult() const { return m_scriptResult.get(); }
+    using Result = Variant<RefPtr<IDBCursor>, RefPtr<IDBDatabase>, JSC::Strong<JSC::Unknown>>;
+    ExceptionOr<std::optional<Result>> result() const;
 
     using Source = Variant<RefPtr<IDBObjectStore>, RefPtr<IDBIndex>, RefPtr<IDBCursor>>;
-    std::optional<Source> source() const;
+    const std::optional<Source>& source() const { return m_source; }
 
     ExceptionOr<DOMError*> error() const;
 
@@ -141,8 +140,6 @@
     IDBRequest(ScriptExecutionContext&, IDBObjectStore&, IndexedDB::ObjectStoreRecordType, IDBTransaction&);
     IDBRequest(ScriptExecutionContext&, IDBIndex&, IndexedDB::IndexRecordType, IDBTransaction&);
 
-    void clearResult();
-
     EventTargetInterface eventTargetInterface() const override;
 
     const char* activeDOMObjectName() const final;
@@ -161,18 +158,11 @@
 
     IDBCursor* resultCursor();
 
-    // Could consider storing these three in a union or union-like class instead.
-    JSC::Strong<JSC::Unknown> m_scriptResult;
-    RefPtr<IDBCursor> m_cursorResult;
-    RefPtr<IDBDatabase> m_databaseResult;
-
     IDBError m_idbError;
     IDBResourceIdentifier m_resourceIdentifier;
 
-    // Could consider storing these three in a union or union-like class instead.
-    RefPtr<IDBObjectStore> m_objectStoreSource;
-    RefPtr<IDBIndex> m_indexSource;
-    RefPtr<IDBCursor> m_cursorSource;
+    std::optional<Result> m_result;
+    std::optional<Source> m_source;
 
     bool m_hasPendingActivity { true };
     IndexedDB::ObjectStoreRecordType m_requestedObjectStoreRecordType { IndexedDB::ObjectStoreRecordType::ValueOnly };

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.idl (210274 => 210275)


--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.idl	2017-01-04 13:59:44 UTC (rev 210274)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.idl	2017-01-04 17:48:58 UTC (rev 210275)
@@ -34,7 +34,7 @@
     GenerateIsReachable=Impl,
     SkipVTableValidation,
 ] interface IDBRequest : EventTarget {
-    [CustomGetter, GetterMayThrowException] readonly attribute any result;
+    [GetterMayThrowException] readonly attribute (IDBCursor or IDBDatabase or any)? result;
     [GetterMayThrowException] readonly attribute DOMError? error;
     readonly attribute (IDBObjectStore or IDBIndex or IDBCursor)? source;
     readonly attribute IDBTransaction transaction;

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (210274 => 210275)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-01-04 13:59:44 UTC (rev 210274)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-01-04 17:48:58 UTC (rev 210275)
@@ -2898,7 +2898,6 @@
 		7CD0BA051B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */; };
 		7CD494CC1A86EB1D000A87EC /* RenderAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */; };
 		7CD494CD1A86EB1D000A87EC /* RenderAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		7CD686561E0E26D300E97AA7 /* JSIDBRequestCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD686551E0E26D300E97AA7 /* JSIDBRequestCustom.cpp */; };
 		7CE58D4A1DD64A5B00128552 /* SVGPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D491DD64A5B00128552 /* SVGPoint.h */; };
 		7CE58D4E1DD694FE00128552 /* SVGRectTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D4D1DD694FE00128552 /* SVGRectTraits.h */; };
 		7CE58D501DD69A1E00128552 /* SVGNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D4F1DD69A1E00128552 /* SVGNumber.h */; };
@@ -10405,7 +10404,6 @@
 		7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActiveDOMCallbackMicrotask.h; sourceTree = "<group>"; };
 		7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderAttachment.cpp; sourceTree = "<group>"; };
 		7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderAttachment.h; sourceTree = "<group>"; };
-		7CD686551E0E26D300E97AA7 /* JSIDBRequestCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBRequestCustom.cpp; sourceTree = "<group>"; };
 		7CE58D491DD64A5B00128552 /* SVGPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPoint.h; sourceTree = "<group>"; };
 		7CE58D4D1DD694FE00128552 /* SVGRectTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGRectTraits.h; sourceTree = "<group>"; };
 		7CE58D4F1DD69A1E00128552 /* SVGNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGNumber.h; sourceTree = "<group>"; };
@@ -22133,7 +22131,6 @@
 				BC17F9650B64EBB8004A65CB /* JSHTMLSelectElementCustom.cpp */,
 				AB4CB4EA0B8BDA3D009F40B0 /* JSHTMLSelectElementCustom.h */,
 				D6F7960C166FFECE0076DD18 /* JSHTMLTemplateElementCustom.cpp */,
-				7CD686551E0E26D300E97AA7 /* JSIDBRequestCustom.cpp */,
 				7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */,
 				BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */,
 				2D9BF7481DBFDDF8007A7D99 /* JSMediaKeySessionCustom.cpp */,
@@ -31741,7 +31738,6 @@
 				49C7B9D91042D32F0009D447 /* WebGLRenderbuffer.cpp in Sources */,
 				49C7B9DF1042D32F0009D447 /* WebGLRenderingContext.cpp in Sources */,
 				D3F3D3691A69B7B00059FC2B /* WebGLRenderingContextBase.cpp in Sources */,
-				7CD686561E0E26D300E97AA7 /* JSIDBRequestCustom.cpp in Sources */,
 				6F995A211A7078B100A735F4 /* WebGLSampler.cpp in Sources */,
 				49C7B9E21042D32F0009D447 /* WebGLShader.cpp in Sources */,
 				A08CF154152B77B3009C5775 /* WebGLShaderPrecisionFormat.cpp in Sources */,

Modified: trunk/Source/WebCore/bindings/generic/IDLTypes.h (210274 => 210275)


--- trunk/Source/WebCore/bindings/generic/IDLTypes.h	2017-01-04 13:59:44 UTC (rev 210274)
+++ trunk/Source/WebCore/bindings/generic/IDLTypes.h	2017-01-04 17:48:58 UTC (rev 210275)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include <heap/HandleTypes.h>
 #include <wtf/Brigand.h>
 #include <wtf/HashMap.h>
 #include <wtf/StdLibExtras.h>
@@ -59,8 +60,15 @@
 // IDLNull is a special type for use as a subtype in an IDLUnion that is nullable.
 struct IDLNull : IDLType<std::nullptr_t> { };
 
-struct IDLAny : IDLType<JSC::JSValue> { };
+struct IDLAny : IDLType<JSC::Strong<JSC::Unknown>> {
+    using ParameterType = JSC::JSValue;
 
+    using NullableType = JSC::Strong<JSC::Unknown>;
+    static inline std::nullptr_t nullValue() { return nullptr; }
+    template<typename U> static inline bool isNullValue(U&& value) { return !value; }
+    template<typename U> static inline U&& extractValueFromNullable(U&& value) { return std::forward<U>(value); }
+};
+
 struct IDLBoolean : IDLType<bool> { };
 
 template<typename NumericType> struct IDLNumber : IDLType<NumericType> { };

Modified: trunk/Source/WebCore/bindings/js/JSDOMConvert.h (210274 => 210275)


--- trunk/Source/WebCore/bindings/js/JSDOMConvert.h	2017-01-04 13:59:44 UTC (rev 210274)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvert.h	2017-01-04 17:48:58 UTC (rev 210275)
@@ -214,10 +214,17 @@
 // MARK: Any type
 
 template<> struct Converter<IDLAny> : DefaultConverter<IDLAny> {
+    using ReturnType = JSC::JSValue;
+    
     static JSC::JSValue convert(JSC::ExecState&, JSC::JSValue value)
     {
         return value;
     }
+
+    static JSC::JSValue convert(const JSC::Strong<JSC::Unknown>& value)
+    {
+        return value.get();
+    }
 };
 
 template<> struct JSConverter<IDLAny> {
@@ -251,6 +258,11 @@
     struct NullableConversionType<IDLInterface<T>> {
         using Type = typename Converter<IDLInterface<T>>::ReturnType;
     };
+
+    template<>
+    struct NullableConversionType<IDLAny> {
+        using Type = typename Converter<IDLAny>::ReturnType;
+    };
 }
 
 template<typename T> struct Converter<IDLNullable<T>> : DefaultConverter<IDLNullable<T>> {

Deleted: trunk/Source/WebCore/bindings/js/JSIDBRequestCustom.cpp (210274 => 210275)


--- trunk/Source/WebCore/bindings/js/JSIDBRequestCustom.cpp	2017-01-04 13:59:44 UTC (rev 210274)
+++ trunk/Source/WebCore/bindings/js/JSIDBRequestCustom.cpp	2017-01-04 17:48:58 UTC (rev 210275)
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSIDBRequest.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "JSIDBCursor.h"
-#include "JSIDBDatabase.h"
-#include "JSIDBIndex.h"
-#include "JSIDBObjectStore.h"
-
-using namespace JSC;
-
-namespace WebCore {
-
-JSValue JSIDBRequest::result(ExecState& state) const
-{
-    auto& request = wrapped();
-
-    if (!request.isDone()) {
-        auto& vm = state.vm();
-        auto scope = DECLARE_THROW_SCOPE(vm);
-        propagateException(state, scope, Exception { IDBDatabaseException::InvalidStateError, ASCIILiteral("Failed to read the 'result' property from 'IDBRequest': The request has not finished.") });
-        return { };
-    }
-
-    if (auto* cursor = request.cursorResult())
-        return toJS(&state, globalObject(), *cursor);
-    if (auto* database = request.databaseResult())
-        return toJS(&state, globalObject(), *database);
-    if (auto result = request.scriptResult())
-        return result;
-    return jsNull();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)

Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (210274 => 210275)


--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2017-01-04 13:59:44 UTC (rev 210274)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2017-01-04 17:48:58 UTC (rev 210275)
@@ -123,17 +123,20 @@
         }
 
         auto& request = static_cast<IDBOpenDBRequest&>(*event->target());
-        if (!request.isDone()) {
+
+        auto result = request.result();
+        if (result.hasException()) {
             m_executableWithDatabase->requestCallback().sendFailure("Could not get result in callback.");
             return;
         }
 
-        auto databaseResult = request.databaseResult();
-        if (!databaseResult) {
+        auto resultValue = result.releaseReturnValue();
+        if (!resultValue || !WTF::holds_alternative<RefPtr<IDBDatabase>>(resultValue.value())) {
             m_executableWithDatabase->requestCallback().sendFailure("Unexpected result type.");
             return;
         }
 
+        auto databaseResult = WTF::get<RefPtr<IDBDatabase>>(resultValue.value());
         m_executableWithDatabase->execute(*databaseResult);
         databaseResult->close();
     }
@@ -362,26 +365,23 @@
         }
 
         auto& request = static_cast<IDBRequest&>(*event->target());
-        if (!request.isDone()) {
+
+        auto result = request.result();
+        if (result.hasException()) {
             m_requestCallback->sendFailure("Could not get result in callback.");
             return;
         }
         
-        if (request.scriptResult()) {
+        auto resultValue = result.releaseReturnValue();
+        if (!resultValue || !WTF::holds_alternative<RefPtr<IDBCursor>>(resultValue.value())) {
             end(false);
             return;
         }
-        
-        auto* cursorResult = request.cursorResult();
-        if (!cursorResult) {
-            end(false);
-            return;
-        }
 
-        auto& cursor = *cursorResult;
+        auto cursor = WTF::get<RefPtr<IDBCursor>>(resultValue.value());
 
         if (m_skipCount) {
-            if (cursor.advance(m_skipCount).hasException())
+            if (cursor->advance(m_skipCount).hasException())
                 m_requestCallback->sendFailure("Could not advance cursor.");
             m_skipCount = 0;
             return;
@@ -393,7 +393,7 @@
         }
 
         // Continue cursor before making injected script calls, otherwise transaction might be finished.
-        if (cursor.continueFunction(nullptr).hasException()) {
+        if (cursor->continueFunction(nullptr).hasException()) {
             m_requestCallback->sendFailure("Could not continue cursor.");
             return;
         }
@@ -403,9 +403,9 @@
             return;
 
         auto dataEntry = DataEntry::create()
-            .setKey(m_injectedScript.wrapObject(cursor.key(), String(), true))
-            .setPrimaryKey(m_injectedScript.wrapObject(cursor.primaryKey(), String(), true))
-            .setValue(m_injectedScript.wrapObject(cursor.value(), String(), true))
+            .setKey(m_injectedScript.wrapObject(cursor->key(), String(), true))
+            .setPrimaryKey(m_injectedScript.wrapObject(cursor->primaryKey(), String(), true))
+            .setValue(m_injectedScript.wrapObject(cursor->value(), String(), true))
             .release();
         m_result->addItem(WTFMove(dataEntry));
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to