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 a4ebac42bf76dc3902f1fd85dc092db2b5ca659d..7891fad3d61fad5b292689a8e4ccfa5e6d55bb29 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 83befd2688c49450f45c808acc0b9e67f0bc2034..3fd99234d90527a477df585a4f12b6df0698113f 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 a9b88b3743b52d9c337fb973b1e5b551fe9b08a0..82f4f13f4b5805db25398a869fa94e891e2f4ca1 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 2e0b922abce3251883d5b56e96dc6bc4f8651740..cdee6d0a44ddfa649c026389fc9d6098346d345f 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 89dbbdf132f886d4cded15609d983cc63f025614..e410f7dd2acc927f4cee9c6b066c8842f7e9ff02 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 3ca61ce66cbccd01517868dd9aa23249fdc9ac75..8ae32d2376d69aa0efbccfb2a1118e7360ca99e3 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 a09548f0a0f81deff77422f928722fc968e138d0..7f490e986562c99af2248e483916de5491b184ed 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 30cfa95071949c99bfd8b38f0c4059777ec76d07..24a946535076d9f0a2cbc33f27717c72d848c4e1 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 1d1efd278d43c1e92f35356b40a8415d3298c9b2..7dad6444bcfc205dfc9239178180cc90f05f4e37 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 1b9b2d1d26ac6c749c5c0a102dc5ebce02f49299..d2c1767b95c02f93a3eed9550e360c2032aecee9 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 0d5a4a606ef79b69e4743d0f7f411a7d3d13a634..817aa5221eefae576c34ac53be9946f0b8a331da 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 9c69675e8e6a46ef4f5312c071a770dc5575b8ab..0505168cb8e622ca345dddaa7ffd167779acec4d 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 4af636fd71940c99cbbf3c4edd0b77ce1e0c24ff..6c1f4600da392ef2d833b34f9b7815030b97a28d 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 e213f4cbc2dd23a86153af3afe619fbf98a425d7..c491fee7f6277bfdde935658a01957e6836a33a6 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 e441425fe3f9928cf4aab1de8a71a51360f2409e..4d379309a8e2eacb21a66ed70fd0bff131ff0e9a 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 579c0d7e02bf0ac6d87c5b89e41ab04f22ff8c08..34890157cb32fd45ae23849cf9f539e396f9553e 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 8ee228715dc623addff2a0ca4db8b07449cbc4bf..78d7e376341d866a104e53570b44a187da8b96fe 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 7c40d7f8856674efbff33b448700d652dee99218..6a2501464b583a572bd6d230991a367ddaf9f790 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 0419bbfdc1680f188474a775105a9c6e5c38fa71..c00484af5fb1a54e2e0d6d05c3597cc7e7f2018a 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 f170289e8ebd69d899d68d494d3b696cc91396ae..2003cacac4f8695f0c5b0d70a9b6b585e7af0657 100644 (file)
@@ -30,6 +30,7 @@
 #include "JSDOMWindowCustom.h"
 #include "JSHTMLCollection.h"
 #include "SegmentedString.h"
+#include <runtime/Lookup.h>
 
 using namespace JSC;
 
index 28fafb4a0c93a6bb1f31737358877eb9b34ee0d1..57eb752da67f4d4024cff4def783f3b409498c6b 100644 (file)
@@ -28,6 +28,7 @@
 #include "JSDOMExceptionHandling.h"
 #include "RuntimeApplicationChecks.h"
 #include <runtime/JSFunction.h>
+#include <runtime/Lookup.h>
 
 using namespace JSC;
 
index 998ee720cda04f21a3e04fd42de8e83e9655df81..5a64c492eda4a456ecbed11477ad4cd139b5fff8 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 9588bac92a8644e7eecd3b6a29522a052597945e..4bc911a707d48ce01d7b68e33782641378f2e3d9 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 cdc3c176e2002e290df0d255ea6b31dfe79d30f4..f7b0978a95f51c2ad43b64b9802f9c1638ceac81 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>