Remove the remaining functions out of JSDOMBinding
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Feb 2017 18:29:15 +0000 (18:29 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Feb 2017 18:29:15 +0000 (18:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168179

Reviewed by Darin Adler.

Move utility functions into more appropriate locations.
Source/JavaScriptCore:

- Move hasIteratorMethod to IteratorOperations.
- Move nonCachingStaticFunctionGetter to Lookup

* runtime/IteratorOperations.cpp:
(JSC::hasIteratorMethod):
* runtime/IteratorOperations.h:
* runtime/Lookup.h:
(JSC::nonCachingStaticFunctionGetter):

Source/WebCore:

- Move hasIteratorMethod to runtime/IteratorOperations.h
- Move nonCachingStaticFunctionGetter to runtime/Lookup.h
- Move addImpureProperty to CommonVM

Remove toJS overload that took a Vector<T>. Replace it's usage
with toJS<IDLSequence<T>> usage. To make this work, added two
new types, IDLIDBKeyData and IDLIDBValue.

* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::setGetResult):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::setResult):
(WebCore::IDBRequest::setResultToStructuredClone):
Adopt JSDOMConvert infrastructure for conversions using new types.

* bindings/IDLTypes.h:
* bindings/js/JSDOMConvertIndexedDB.h:
(WebCore::JSConverter<IDLIDBKeyData>::convert):
(WebCore::JSConverter<IDLIDBValue>::convert):
Add new types for IDBKeyData and IDBValue.

* bindings/js/CommonVM.cpp:
(WebCore::addImpureProperty):
* bindings/js/CommonVM.h:
Move addImpureProperty here from JSDOMBinding.

* bindings/js/IDBBindingUtilities.cpp:
(WebCore::idbKeyDataToScriptValue): Deleted.
* bindings/js/IDBBindingUtilities.h:
Remove unused idbKeyDataToScriptValue, and group like functions
together.

* bindings/js/JSDOMBinding.cpp: Removed.
* bindings/js/JSDOMBinding.h:
(WebCore::nonCachingStaticFunctionGetter): Deleted.
(WebCore::toJS): Deleted.
Move/remove functions.

* bindings/js/JSDOMConvertUnion.h:
Update for move of hasIteratorMethod to runtime/IteratorOperations.h

* bindings/js/JSDOMWindowCustom.cpp:
* bindings/js/JSHTMLDocumentCustom.cpp:
* bindings/js/JSLocationCustom.cpp:
Update for move of nonCachingStaticFunctionGetter to runtime/Lookup.h

* bindings/js/JSSubtleCryptoCustom.cpp:
Remove unneeded include of runtime/IteratorOperations.h

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateOverloadedFunctionOrConstructor):
Include runtime/IteratorOperations when needing to distinguish a sequence.

* html/HTMLDocument.cpp:
Replace include of JSDOMBinding.h with CommonVM.h for addImpureProperty.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212207 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/IteratorOperations.cpp
Source/JavaScriptCore/runtime/IteratorOperations.h
Source/JavaScriptCore/runtime/Lookup.h
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBCursor.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/IDLTypes.h
Source/WebCore/bindings/js/CommonVM.cpp
Source/WebCore/bindings/js/CommonVM.h
Source/WebCore/bindings/js/IDBBindingUtilities.cpp
Source/WebCore/bindings/js/IDBBindingUtilities.h
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSDOMBinding.cpp [deleted file]
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMConvertIndexedDB.h
Source/WebCore/bindings/js/JSDOMConvertUnion.h
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
Source/WebCore/bindings/js/JSLocationCustom.cpp
Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/html/HTMLDocument.cpp

index a4ebac4..7891fad 100644 (file)
@@ -1,3 +1,20 @@
+2017-02-11  Sam Weinig  <sam@webkit.org>
+
+        Remove the remaining functions out of JSDOMBinding
+        https://bugs.webkit.org/show_bug.cgi?id=168179
+
+        Reviewed by Darin Adler.
+
+        Move utility functions into more appropriate locations.
+        - Move hasIteratorMethod to IteratorOperations.
+        - Move nonCachingStaticFunctionGetter to Lookup
+
+        * runtime/IteratorOperations.cpp:
+        (JSC::hasIteratorMethod):
+        * runtime/IteratorOperations.h:
+        * runtime/Lookup.h:
+        (JSC::nonCachingStaticFunctionGetter):
+
 2017-02-11  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [JSC] Implement (Shared)ArrayBuffer.prototype.byteLength
index 83befd2..3fd9923 100644 (file)
@@ -159,12 +159,29 @@ JSObject* createIteratorResultObject(ExecState* exec, JSValue value, bool done)
     return resultObject;
 }
 
+bool hasIteratorMethod(ExecState& state, JSValue value)
+{
+    auto& vm = state.vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    if (!value.isObject())
+        return false;
+
+    JSObject* object = asObject(value);
+    CallData callData;
+    CallType callType;
+    JSValue applyMethod = object->getMethod(&state, callData, callType, vm.propertyNames->iteratorSymbol, ASCIILiteral("Symbol.iterator property should be callable"));
+    RETURN_IF_EXCEPTION(scope, false);
+
+    return !applyMethod.isUndefined();
+}
+
 JSValue iteratorForIterable(ExecState* state, JSValue iterable)
 {
     VM& vm = state->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
     
-    JSValue iteratorFunction = iterable.get(state, state->propertyNames().iteratorSymbol);
+    JSValue iteratorFunction = iterable.get(state, vm.propertyNames->iteratorSymbol);
     RETURN_IF_EXCEPTION(scope, JSValue());
     
     CallData iteratorFunctionCallData;
index a9b88b3..82f4f13 100644 (file)
@@ -42,6 +42,7 @@ JS_EXPORT_PRIVATE JSObject* createIteratorResultObject(ExecState*, JSValue, bool
 
 Structure* createIteratorResultObjectStructure(VM&, JSGlobalObject&);
 
+JS_EXPORT_PRIVATE bool hasIteratorMethod(ExecState&, JSValue);
 JS_EXPORT_PRIVATE JSValue iteratorForIterable(ExecState*, JSValue iterable);
 
 template <typename CallBackType>
index 2e0b922..cdee6d0 100644 (file)
@@ -387,4 +387,9 @@ inline void reifyStaticProperties(VM& vm, const HashTableValue (&values)[numberO
     }
 }
 
+template<NativeFunction nativeFunction, int length> EncodedJSValue nonCachingStaticFunctionGetter(ExecState* state, EncodedJSValue, PropertyName propertyName)
+{
+    return JSValue::encode(JSFunction::create(state->vm(), state->lexicalGlobalObject(), length, propertyName.publicName(), nativeFunction));
+}
+
 } // namespace JSC
index 89dbbdf..e410f7d 100644 (file)
@@ -1103,7 +1103,6 @@ set(WebCore_SOURCES
     bindings/js/JSCustomElementRegistryCustom.cpp
     bindings/js/JSCustomEventCustom.cpp
     bindings/js/JSCustomXPathNSResolver.cpp
-    bindings/js/JSDOMBinding.cpp
     bindings/js/JSDOMBindingSecurity.cpp
     bindings/js/JSDOMBuiltinConstructorBase.cpp
     bindings/js/JSDOMConstructorBase.cpp
index 3ca61ce..8ae32d2 100644 (file)
@@ -1,3 +1,67 @@
+2017-02-11  Sam Weinig  <sam@webkit.org>
+
+        Remove the remaining functions out of JSDOMBinding
+        https://bugs.webkit.org/show_bug.cgi?id=168179
+
+        Reviewed by Darin Adler.
+
+        Move utility functions into more appropriate locations.
+        - Move hasIteratorMethod to runtime/IteratorOperations.h
+        - Move nonCachingStaticFunctionGetter to runtime/Lookup.h
+        - Move addImpureProperty to CommonVM
+
+        Remove toJS overload that took a Vector<T>. Replace it's usage
+        with toJS<IDLSequence<T>> usage. To make this work, added two
+        new types, IDLIDBKeyData and IDLIDBValue.
+
+        * Modules/indexeddb/IDBCursor.cpp:
+        (WebCore::IDBCursor::setGetResult):
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::setResult):
+        (WebCore::IDBRequest::setResultToStructuredClone):
+        Adopt JSDOMConvert infrastructure for conversions using new types.
+
+        * bindings/IDLTypes.h:
+        * bindings/js/JSDOMConvertIndexedDB.h:
+        (WebCore::JSConverter<IDLIDBKeyData>::convert):
+        (WebCore::JSConverter<IDLIDBValue>::convert):
+        Add new types for IDBKeyData and IDBValue.
+
+        * bindings/js/CommonVM.cpp:
+        (WebCore::addImpureProperty):
+        * bindings/js/CommonVM.h:
+        Move addImpureProperty here from JSDOMBinding.
+
+        * bindings/js/IDBBindingUtilities.cpp:
+        (WebCore::idbKeyDataToScriptValue): Deleted.
+        * bindings/js/IDBBindingUtilities.h:
+        Remove unused idbKeyDataToScriptValue, and group like functions
+        together.
+
+        * bindings/js/JSDOMBinding.cpp: Removed.
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::nonCachingStaticFunctionGetter): Deleted.
+        (WebCore::toJS): Deleted.
+        Move/remove functions.
+
+        * bindings/js/JSDOMConvertUnion.h:
+        Update for move of hasIteratorMethod to runtime/IteratorOperations.h
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        * bindings/js/JSHTMLDocumentCustom.cpp:
+        * bindings/js/JSLocationCustom.cpp:
+        Update for move of nonCachingStaticFunctionGetter to runtime/Lookup.h
+
+        * bindings/js/JSSubtleCryptoCustom.cpp:
+        Remove unneeded include of runtime/IteratorOperations.h
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateOverloadedFunctionOrConstructor):
+        Include runtime/IteratorOperations when needing to distinguish a sequence.
+
+        * html/HTMLDocument.cpp:
+        Replace include of JSDOMBinding.h with CommonVM.h for addImpureProperty.
+
 2017-02-12  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Handle caps lock indicator in event modifiers
index a09548f..7f490e9 100644 (file)
@@ -345,9 +345,11 @@ void IDBCursor::setGetResult(IDBRequest& request, const IDBGetResult& getResult)
 
     auto& vm = context->vm();
 
-    m_currentKey = { vm, idbKeyDataToScriptValue(*exec, getResult.keyData()) };
+    // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object
+    // of the IDBCursor wrapper can be used, rather than the lexicalGlobalObject.
+    m_currentKey = { vm, toJS(*exec, *exec->lexicalGlobalObject(), getResult.keyData().maybeCreateIDBKey().get()) };
     m_currentKeyData = getResult.keyData();
-    m_currentPrimaryKey = { vm, idbKeyDataToScriptValue(*exec, getResult.primaryKeyData()) };
+    m_currentPrimaryKey = { vm, toJS(*exec, *exec->lexicalGlobalObject(), getResult.primaryKeyData().maybeCreateIDBKey().get()) };
     m_currentPrimaryKeyData = getResult.primaryKeyData();
 
     if (isKeyCursorWithValue())
index 30cfa95..24a9465 100644 (file)
@@ -364,11 +364,13 @@ void IDBRequest::setResult(const IDBKeyData& keyData)
     if (!context)
         return;
 
-    auto* exec = context->execState();
-    if (!exec)
+    auto* state = context->execState();
+    if (!state)
         return;
 
-    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), idbKeyDataToScriptValue(*exec, keyData) } };
+    // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object
+    // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject.
+    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), toJS<IDLIDBKeyData>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), keyData) } };
 }
 
 void IDBRequest::setResult(const Vector<IDBKeyData>& keyDatas)
@@ -383,9 +385,10 @@ void IDBRequest::setResult(const Vector<IDBKeyData>& keyDatas)
     if (!state)
         return;
 
-
+    // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object
+    // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject.
     Locker<JSLock> locker(context->vm().apiLock());
-    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), toJS(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), keyDatas) } };
+    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), toJS<IDLSequence<IDLIDBKeyData>>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), keyDatas) } };
 }
 
 void IDBRequest::setResult(const Vector<IDBValue>& values)
@@ -396,12 +399,14 @@ void IDBRequest::setResult(const Vector<IDBValue>& values)
     if (!context)
         return;
 
-    auto* exec = context->execState();
-    if (!exec)
+    auto* state = context->execState();
+    if (!state)
         return;
 
+    // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object
+    // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject.
     Locker<JSLock> locker(context->vm().apiLock());
-    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), toJS(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), values) } };
+    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), toJS<IDLSequence<IDLIDBValue>>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), values) } };
 }
 
 void IDBRequest::setResult(uint64_t number)
@@ -412,7 +417,7 @@ void IDBRequest::setResult(uint64_t number)
     if (!context)
         return;
 
-    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), JSC::jsNumber(number) } };
+    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), toJS<IDLUnrestrictedDouble>(number) } };
 }
 
 void IDBRequest::setResultToStructuredClone(const IDBValue& value)
@@ -425,11 +430,13 @@ void IDBRequest::setResultToStructuredClone(const IDBValue& value)
     if (!context)
         return;
 
-    auto* exec = context->execState();
-    if (!exec)
+    auto* state = context->execState();
+    if (!state)
         return;
 
-    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), deserializeIDBValueToJSValue(*exec, value) } };
+    // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object
+    // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject.
+    m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), toJS<IDLIDBValue>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), value) } };
 }
 
 void IDBRequest::setResultToUndefined()
index 1d1efd2..7dad644 100644 (file)
                93B2D8160F9920D2006AE6B2 /* SuddenTermination.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B2D8150F9920D2006AE6B2 /* SuddenTermination.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93B2D8180F9920EE006AE6B2 /* SuddenTermination.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93B2D8170F9920EE006AE6B2 /* SuddenTermination.mm */; };
                93B6A0E60B0BCA5C00F5027A /* ContextMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               93B70D6309EB0C7C009D8468 /* JSDOMBinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D4709EB0C7C009D8468 /* JSDOMBinding.cpp */; };
                93B70D6409EB0C7C009D8468 /* JSDOMBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93B70D6909EB0C7C009D8468 /* JSEventListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D4D09EB0C7C009D8468 /* JSEventListener.cpp */; };
                93B70D6A09EB0C7C009D8468 /* JSEventListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D4E09EB0C7C009D8468 /* JSEventListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93B2D8150F9920D2006AE6B2 /* SuddenTermination.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SuddenTermination.h; sourceTree = "<group>"; };
                93B2D8170F9920EE006AE6B2 /* SuddenTermination.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SuddenTermination.mm; sourceTree = "<group>"; };
                93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ContextMenu.h; sourceTree = "<group>"; };
-               93B70D4709EB0C7C009D8468 /* JSDOMBinding.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMBinding.cpp; sourceTree = "<group>"; };
                93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSDOMBinding.h; sourceTree = "<group>"; };
                93B70D4D09EB0C7C009D8468 /* JSEventListener.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSEventListener.cpp; sourceTree = "<group>"; };
                93B70D4E09EB0C7C009D8468 /* JSEventListener.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSEventListener.h; sourceTree = "<group>"; };
                                E125F83C182411E700D84CD9 /* JSCryptoOperationData.h */,
                                9BD4E9141C462872005065BC /* JSCustomElementInterface.cpp */,
                                9BD4E9151C462872005065BC /* JSCustomElementInterface.h */,
-                               93B70D4709EB0C7C009D8468 /* JSDOMBinding.cpp */,
                                93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */,
                                7C45C9C61E3E8ABA00AAB558 /* JSDOMBindingCaller.h */,
                                7C45C9CA1E3E8D2E00AAB558 /* JSDOMBindingSecurity.cpp */,
                                1221E05F1C02B444006A1A00 /* JSDocumentTimeline.cpp in Sources */,
                                65DF31F509D1CC60000BE325 /* JSDocumentType.cpp in Sources */,
                                1AC2260C0DB69F190089B669 /* JSDOMApplicationCache.cpp in Sources */,
-                               93B70D6309EB0C7C009D8468 /* JSDOMBinding.cpp in Sources */,
                                7C45C9CF1E3EFDF700AAB558 /* JSDOMBindingSecurity.cpp in Sources */,
                                BC60D7C00D29A46300B9918F /* JSDOMCoreException.cpp in Sources */,
                                FD67773B195CB1E60072E0D3 /* JSDOMCSSNamespace.cpp in Sources */,
index 1b9b2d1..d2c1767 100644 (file)
@@ -46,6 +46,8 @@ template<typename> class Strong;
 namespace WebCore {
 
 class IDBKey;
+class IDBKeyData;
+class IDBValue;
 template<typename> class DOMPromise;
 
 template<typename T>
@@ -200,6 +202,8 @@ template<typename T> struct IDLEventListener : IDLWrapper<T> { };
 template<typename T> struct IDLXPathNSResolver : IDLWrapper<T> { };
 
 struct IDLIDBKey : IDLWrapper<IDBKey> { };
+struct IDLIDBKeyData : IDLWrapper<IDBKeyData> { };
+struct IDLIDBValue : IDLWrapper<IDBValue> { };
 
 #if ENABLE(WEBGL)
 struct IDLWebGLAny : IDLType<WebGLAny> { };
index 0d5a4a6..817aa52 100644 (file)
@@ -32,6 +32,7 @@
 #include <heap/HeapInlines.h>
 #include <runtime/VM.h>
 #include <wtf/MainThread.h>
+#include <wtf/text/AtomicString.h>
 
 using namespace JSC;
 
@@ -61,5 +62,10 @@ VM& commonVMSlow()
     return *g_commonVMOrNull;
 }
 
+void addImpureProperty(const AtomicString& propertyName)
+{
+    commonVM().addImpureProperty(propertyName);
+}
+
 } // namespace WebCore
 
index 9c69675..0505168 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#include <wtf/Forward.h>
+
 namespace JSC {
 class VM;
 }
@@ -42,5 +44,7 @@ inline JSC::VM& commonVM()
     return commonVMSlow();
 }
 
+void addImpureProperty(const AtomicString&);
+
 } // namespace WebCore
 
index 4af636f..6c1f460 100644 (file)
@@ -367,12 +367,6 @@ Ref<IDBKey> scriptValueToIDBKey(ExecState& exec, const JSValue& scriptValue)
     return createIDBKeyFromValue(exec, scriptValue);
 }
 
-JSC::JSValue idbKeyDataToScriptValue(JSC::ExecState& exec, const IDBKeyData& keyData)
-{
-    RefPtr<IDBKey> key = keyData.maybeCreateIDBKey();
-    return toJS(exec, *exec.lexicalGlobalObject(), key.get());
-}
-
 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, const IDBKeyData& keyData)
 {
     ASSERT(state);
index e213f4c..c491fee 100644 (file)
@@ -46,21 +46,18 @@ class IDBValue;
 class IndexKey;
 class JSDOMGlobalObject;
 
-
 RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(JSC::ExecState&, const JSC::JSValue&, const IDBKeyPath&);
 bool canInjectIDBKeyIntoScriptValue(JSC::ExecState&, const JSC::JSValue&, const IDBKeyPath&);
 bool injectIDBKeyIntoScriptValue(JSC::ExecState&, const IDBKeyData&, JSC::JSValue, const IDBKeyPath&);
 
-JSC::JSValue toJS(JSC::ExecState&, JSC::JSGlobalObject&, IDBKey*);
-JSC::JSValue idbKeyDataToScriptValue(JSC::ExecState&, const IDBKeyData&);
 void generateIndexKeyForValue(JSC::ExecState&, const IDBIndexInfo&, JSC::JSValue, IndexKey& outKey);
 
-JSC::JSValue deserializeIDBValueToJSValue(JSC::ExecState&, const IDBValue&);
-
 Ref<IDBKey> scriptValueToIDBKey(JSC::ExecState&, const JSC::JSValue&);
 
-JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const IDBKeyData&);
+JSC::JSValue deserializeIDBValueToJSValue(JSC::ExecState&, const IDBValue&);
 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const IDBValue&);
+JSC::JSValue toJS(JSC::ExecState&, JSC::JSGlobalObject&, IDBKey*);
+JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const IDBKeyData&);
 
 }
 
index e441425..4d37930 100644 (file)
@@ -44,7 +44,6 @@
 #include "JSCustomEventCustom.cpp"
 #include "JSSQLStatementErrorCallbackCustom.cpp"
 #include "JSCustomXPathNSResolver.cpp"
-#include "JSDOMBinding.cpp"
 #include "JSDOMBindingSecurity.cpp"
 #include "JSDOMBuiltinConstructorBase.cpp"
 #include "JSDOMConstructorBase.cpp"
diff --git a/Source/WebCore/bindings/js/JSDOMBinding.cpp b/Source/WebCore/bindings/js/JSDOMBinding.cpp
deleted file mode 100644 (file)
index 2b139b5..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
- *  Copyright (C) 2004-2011, 2013, 2016 Apple Inc. All rights reserved.
- *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
- *  Copyright (C) 2013 Michael Pruett <michael@68k.org>
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "config.h"
-#include "JSDOMBinding.h"
-
-#include "CommonVM.h"
-
-using namespace JSC;
-
-namespace WebCore {
-
-void addImpureProperty(const AtomicString& propertyName)
-{
-    commonVM().addImpureProperty(propertyName);
-}
-
-bool hasIteratorMethod(JSC::ExecState& state, JSC::JSValue value)
-{
-    auto& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (!value.isObject())
-        return false;
-
-    JSObject* object = JSC::asObject(value);
-    CallData callData;
-    CallType callType;
-    JSValue applyMethod = object->getMethod(&state, callData, callType, vm.propertyNames->iteratorSymbol, ASCIILiteral("Symbol.iterator property should be callable"));
-    RETURN_IF_EXCEPTION(scope, false);
-
-    return !applyMethod.isUndefined();
-}
-
-} // namespace WebCore
index 579c0d7..3489015 100644 (file)
@@ -23,6 +23,8 @@
 
 #pragma once
 
+// FIXME: Remove this header.
+
 #include "ExceptionOr.h"
 #include "JSDOMWrapperCache.h"
 #include <cstddef>
 #include <wtf/Forward.h>
 #include <wtf/GetPtr.h>
 #include <wtf/Vector.h>
-
-namespace JSC {
-class JSFunction;
-}
-
-namespace WebCore {
-
-void addImpureProperty(const AtomicString&);
-
-WEBCORE_EXPORT bool hasIteratorMethod(JSC::ExecState&, JSC::JSValue);
-
-template<JSC::NativeFunction nativeFunction, int length> JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState* exec, JSC::EncodedJSValue, JSC::PropertyName propertyName)
-{
-    return JSC::JSValue::encode(JSC::JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), length, propertyName.publicName(), nativeFunction));
-}
-
-template<typename T> inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<T>& vector)
-{
-    JSC::VM& vm = globalObject->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSC::JSArray* array = constructEmptyArray(exec, nullptr, vector.size());
-    RETURN_IF_EXCEPTION(scope, JSC::JSValue());
-    for (size_t i = 0; i < vector.size(); ++i) {
-        array->putDirectIndex(exec, i, toJS(exec, globalObject, vector[i]));
-        RETURN_IF_EXCEPTION(scope, JSC::JSValue());
-    }
-    return array;
-}
-
-} // namespace WebCore
index 8ee2287..78d7e37 100644 (file)
@@ -44,6 +44,28 @@ template<> struct JSConverter<IDLIDBKey> {
     }
 };
 
+template<> struct JSConverter<IDLIDBKeyData> {
+    static constexpr bool needsState = true;
+    static constexpr bool needsGlobalObject = true;
+
+    template <typename U>
+    static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, U&& value)
+    {
+        return toJS(&state, &globalObject, std::forward<U>(value));
+    }
+};
+
+template<> struct JSConverter<IDLIDBValue> {
+    static constexpr bool needsState = true;
+    static constexpr bool needsGlobalObject = true;
+
+    template <typename U>
+    static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, U&& value)
+    {
+        return toJS(&state, &globalObject, std::forward<U>(value));
+    }
+};
+
 } // namespace WebCore
 
 #endif
index 7c40d7f..6a25014 100644 (file)
@@ -28,6 +28,7 @@
 #include "IDLTypes.h"
 #include "JSDOMBinding.h"
 #include "JSDOMConvertBase.h"
+#include <runtime/IteratorOperations.h>
 
 namespace WebCore {
 
@@ -183,7 +184,7 @@ template<typename... T> struct Converter<IDLUnion<T...>> : DefaultConverter<IDLU
                     //            sequence of that type from V and method.        
                     constexpr bool hasSequenceType = numberOfSequenceTypes != 0;
                     if (hasSequenceType) {
-                        bool hasIterator = hasIteratorMethod(state, value);
+                        bool hasIterator = JSC::hasIteratorMethod(state, value);
                         RETURN_IF_EXCEPTION(scope, ReturnType());
                         if (hasIterator)
                             return std::move<WTF::CheckMoveParameter>(ConditionalConverter<ReturnType, SequenceType, hasSequenceType>::convert(state, value).value());
@@ -196,7 +197,7 @@ template<typename... T> struct Converter<IDLUnion<T...>> : DefaultConverter<IDLU
                     //            frozen array of that type from V and method.
                     constexpr bool hasFrozenArrayType = numberOfFrozenArrayTypes != 0;
                     if (hasFrozenArrayType) {
-                        bool hasIterator = hasIteratorMethod(state, value);
+                        bool hasIterator = JSC::hasIteratorMethod(state, value);
                         RETURN_IF_EXCEPTION(scope, ReturnType());
                         if (hasIterator)
                             return std::move<WTF::CheckMoveParameter>(ConditionalConverter<ReturnType, FrozenArrayType, hasFrozenArrayType>::convert(state, value).value());
index 0419bbf..c00484a 100644 (file)
@@ -39,6 +39,7 @@
 #include "ScheduledAction.h"
 #include "Settings.h"
 #include <runtime/JSCInlines.h>
+#include <runtime/Lookup.h>
 
 #if ENABLE(USER_MESSAGE_HANDLERS)
 #include "JSWebKitNamespace.h"
index f170289..2003cac 100644 (file)
@@ -30,6 +30,7 @@
 #include "JSDOMWindowCustom.h"
 #include "JSHTMLCollection.h"
 #include "SegmentedString.h"
+#include <runtime/Lookup.h>
 
 using namespace JSC;
 
index 28fafb4..57eb752 100644 (file)
@@ -28,6 +28,7 @@
 #include "JSDOMExceptionHandling.h"
 #include "RuntimeApplicationChecks.h"
 #include <runtime/JSFunction.h>
+#include <runtime/Lookup.h>
 
 using namespace JSC;
 
index 998ee72..5a64c49 100644 (file)
@@ -45,7 +45,6 @@
 #include "JSRsaOaepParams.h"
 #include "ScriptState.h"
 #include <runtime/Error.h>
-#include <runtime/IteratorOperations.h>
 #include <runtime/JSArray.h>
 #include <runtime/JSONObject.h>
 
index 9588bac..4bc911a 100644 (file)
@@ -2558,13 +2558,14 @@ sub GenerateOverloadedFunctionOrConstructor
     }
 
     my $generateOverloadCallIfNecessary = sub {
-        my ($overload, $condition) = @_;
+        my ($overload, $condition, $include) = @_;
         return unless $overload;
         my $conditionalString = $codeGenerator->GenerateConditionalString($overload);
         push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
         push(@implContent, "        if ($condition)\n    ") if $condition;
         push(@implContent, "        return ${functionName}$overload->{overloadIndex}(state);\n");
         push(@implContent, "#endif\n") if $conditionalString;
+        AddToImplIncludes($include, $overload->extendedAttributes->{"Conditional"}) if $include;
     };
     my $isOptionalParameter = sub {
         my ($type, $optionality) = @_;
@@ -2695,7 +2696,7 @@ END
 
             # FIXME: Avoid invoking GetMethod(object, Symbol.iterator) again in convert<IDLSequence<T>>(...).
             $overload = GetOverloadThatMatches($S, $d, \&$isSequenceOrFrozenArrayParameter);
-            &$generateOverloadCallIfNecessary($overload, "hasIteratorMethod(*state, distinguishingArg)");
+            &$generateOverloadCallIfNecessary($overload, "hasIteratorMethod(*state, distinguishingArg)", "<runtime/IteratorOperations.h>");
 
             $overload = GetOverloadThatMatches($S, $d, \&$isDictionaryOrRecordOrObjectOrCallbackInterfaceParameter);
             &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->type() != RegExpObjectType");
index cdc3c17..f7b0978 100644 (file)
@@ -54,6 +54,7 @@
 #include "HTMLDocument.h"
 
 #include "CSSPropertyNames.h"
+#include "CommonVM.h"
 #include "CookieJar.h"
 #include "DocumentLoader.h"
 #include "DocumentType.h"
 #include "FrameLoader.h"
 #include "FrameTree.h"
 #include "FrameView.h"
-#include "HashTools.h"
-#include "HTMLDocumentParser.h"
 #include "HTMLBodyElement.h"
+#include "HTMLDocumentParser.h"
 #include "HTMLElementFactory.h"
 #include "HTMLFrameOwnerElement.h"
 #include "HTMLFrameSetElement.h"
 #include "HTMLHtmlElement.h"
 #include "HTMLNames.h"
-#include "JSDOMBinding.h"
+#include "HashTools.h"
 #include "ScriptController.h"
 #include "StyleResolver.h"
 #include <wtf/text/CString.h>