Title: [209674] trunk/Source/WebCore
Revision
209674
Author
[email protected]
Date
2016-12-10 14:13:58 -0800 (Sat, 10 Dec 2016)

Log Message

[WebIDL] Merge JSDictionary into Dictionary, and remove unused bits
https://bugs.webkit.org/show_bug.cgi?id=165641

Reviewed by Dan Bernstein.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSBindingsAllInOne.cpp:
Remove JSDictionary.h/cpp

* Modules/mediastream/RTCDataChannel.cpp:
Remove unused #include of Dictionary.h

* Modules/mediastream/RTCPeerConnection.cpp:
* Modules/mediastream/RTCPeerConnection.h:
Replace unnecessary #include of Dictionary in a header with forward declaration.

* bindings/js/Dictionary.cpp:
(WebCore::Dictionary::Dictionary):
(WebCore::Dictionary::tryGetProperty):
(WebCore::Dictionary::getOwnPropertyNames):
(WebCore::Dictionary::convertValue):
(WebCore::Dictionary::asJSObject<Notification>): Deleted.
(WebCore::Dictionary::getOwnPropertiesAsStringHashMap): Deleted.
(WebCore::Dictionary::getWithUndefinedOrNullCheck): Deleted.
* bindings/js/Dictionary.h:
(WebCore::Dictionary::isObject):
(WebCore::Dictionary::isUndefinedOrNull):
(WebCore::Dictionary::execState):
(WebCore::Dictionary::initializerObject):
(WebCore::Dictionary::isValid):
(WebCore::Dictionary::convertValue):
(WebCore::Dictionary::get):
(WebCore::Dictionary::tryGetPropertyAndResult):
(WebCore::Dictionary::getEventListener): Deleted.
Merge JSDictionary into Dictionary. Remove all unused functions (some getters, lots
of convertValue overrides). Modernize to taste.

* bindings/js/JSCryptoAlgorithmDictionary.cpp:
(WebCore::JSCryptoAlgorithmDictionary::getAlgorithmIdentifier):
(WebCore::getHashAlgorithm):
(WebCore::createHmacParams):
(WebCore::createHmacKeyParams):
(WebCore::createRsaKeyGenParams):
(WebCore::createRsaOaepParams):
(WebCore::createRsaSsaParams):
Update for rename. JSDictionary is now Dictionary.

* bindings/js/JSDictionary.cpp: Removed.
* bindings/js/JSDictionary.h: Removed.

* dom/MutationObserver.cpp:
Remove unused #include of Dictionary.h

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (209673 => 209674)


--- trunk/Source/WebCore/CMakeLists.txt	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-12-10 22:13:58 UTC (rev 209674)
@@ -1123,7 +1123,6 @@
     bindings/js/JSDataTransferCustom.cpp
     bindings/js/JSDeviceMotionEventCustom.cpp
     bindings/js/JSDeviceOrientationEventCustom.cpp
-    bindings/js/JSDictionary.cpp
     bindings/js/JSDocumentCustom.cpp
     bindings/js/JSDocumentFragmentCustom.cpp
     bindings/js/JSElementCustom.cpp

Modified: trunk/Source/WebCore/ChangeLog (209673 => 209674)


--- trunk/Source/WebCore/ChangeLog	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/ChangeLog	2016-12-10 22:13:58 UTC (rev 209674)
@@ -1,3 +1,59 @@
+2016-12-10  Sam Weinig  <[email protected]>
+
+        [WebIDL] Merge JSDictionary into Dictionary, and remove unused bits
+        https://bugs.webkit.org/show_bug.cgi?id=165641
+
+        Reviewed by Dan Bernstein.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSBindingsAllInOne.cpp:
+        Remove JSDictionary.h/cpp
+
+        * Modules/mediastream/RTCDataChannel.cpp:
+        Remove unused #include of Dictionary.h
+
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        * Modules/mediastream/RTCPeerConnection.h:
+        Replace unnecessary #include of Dictionary in a header with forward declaration.
+
+        * bindings/js/Dictionary.cpp:
+        (WebCore::Dictionary::Dictionary):
+        (WebCore::Dictionary::tryGetProperty):
+        (WebCore::Dictionary::getOwnPropertyNames):
+        (WebCore::Dictionary::convertValue):
+        (WebCore::Dictionary::asJSObject<Notification>): Deleted.
+        (WebCore::Dictionary::getOwnPropertiesAsStringHashMap): Deleted.
+        (WebCore::Dictionary::getWithUndefinedOrNullCheck): Deleted.
+        * bindings/js/Dictionary.h:
+        (WebCore::Dictionary::isObject):
+        (WebCore::Dictionary::isUndefinedOrNull):
+        (WebCore::Dictionary::execState):
+        (WebCore::Dictionary::initializerObject):
+        (WebCore::Dictionary::isValid):
+        (WebCore::Dictionary::convertValue):
+        (WebCore::Dictionary::get):
+        (WebCore::Dictionary::tryGetPropertyAndResult):
+        (WebCore::Dictionary::getEventListener): Deleted.
+        Merge JSDictionary into Dictionary. Remove all unused functions (some getters, lots
+        of convertValue overrides). Modernize to taste.
+
+        * bindings/js/JSCryptoAlgorithmDictionary.cpp:
+        (WebCore::JSCryptoAlgorithmDictionary::getAlgorithmIdentifier):
+        (WebCore::getHashAlgorithm):
+        (WebCore::createHmacParams):
+        (WebCore::createHmacKeyParams):
+        (WebCore::createRsaKeyGenParams):
+        (WebCore::createRsaOaepParams):
+        (WebCore::createRsaSsaParams):
+        Update for rename. JSDictionary is now Dictionary.
+
+        * bindings/js/JSDictionary.cpp: Removed.
+        * bindings/js/JSDictionary.h: Removed.
+
+        * dom/MutationObserver.cpp:
+        Remove unused #include of Dictionary.h
+
 2016-12-10  Dave Hyatt  <[email protected]>
 
         [CSS Parser] Move CSSParserValues.h/.cpp to CSSParserSelector.h/.cpp

Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp (209673 => 209674)


--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp	2016-12-10 22:13:58 UTC (rev 209674)
@@ -29,7 +29,6 @@
 #include "RTCDataChannel.h"
 
 #include "Blob.h"
-#include "Dictionary.h"
 #include "Event.h"
 #include "EventNames.h"
 #include "MessageEvent.h"

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (209673 => 209674)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2016-12-10 22:13:58 UTC (rev 209674)
@@ -35,6 +35,7 @@
 
 #if ENABLE(WEB_RTC)
 
+#include "Dictionary.h"
 #include "Document.h"
 #include "Event.h"
 #include "EventNames.h"

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (209673 => 209674)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2016-12-10 22:13:58 UTC (rev 209674)
@@ -35,7 +35,6 @@
 #if ENABLE(WEB_RTC)
 
 #include "ActiveDOMObject.h"
-#include "Dictionary.h"
 #include "EventTarget.h"
 #include "MediaStream.h"
 #include "RTCDataChannel.h"
@@ -47,6 +46,7 @@
 
 namespace WebCore {
 
+class Dictionary;
 class MediaStreamTrack;
 class PeerConnectionBackend;
 class RTCConfiguration;

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (209673 => 209674)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-12-10 22:13:58 UTC (rev 209674)
@@ -5489,8 +5489,6 @@
 		BCE1C4400D9830F4003B02F2 /* JSLocationCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */; };
 		BCE32B9C1517C0B200F542EC /* RenderMultiColumnSet.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE32B9B1517C0B100F542EC /* RenderMultiColumnSet.h */; };
 		BCE32B9E1517C22700F542EC /* RenderMultiColumnSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE32B9D1517C22700F542EC /* RenderMultiColumnSet.cpp */; };
-		BCE4389C140B1BA8005E437E /* JSDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE4389B140B1BA7005E437E /* JSDictionary.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		BCE438A2140C0DC0005E437E /* JSDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE438A1140C0DBF005E437E /* JSDictionary.cpp */; };
 		BCE4413312F748E2009B84B8 /* RenderCombineText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE4413112F748E2009B84B8 /* RenderCombineText.cpp */; };
 		BCE4413412F748E2009B84B8 /* RenderCombineText.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE4413212F748E2009B84B8 /* RenderCombineText.h */; };
 		BCE658FF0EA9248A007E4533 /* Theme.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE658FE0EA9248A007E4533 /* Theme.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -13384,8 +13382,6 @@
 		BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSLocationCustom.cpp; sourceTree = "<group>"; };
 		BCE32B9B1517C0B100F542EC /* RenderMultiColumnSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMultiColumnSet.h; sourceTree = "<group>"; };
 		BCE32B9D1517C22700F542EC /* RenderMultiColumnSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMultiColumnSet.cpp; sourceTree = "<group>"; };
-		BCE4389B140B1BA7005E437E /* JSDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDictionary.h; sourceTree = "<group>"; };
-		BCE438A1140C0DBF005E437E /* JSDictionary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDictionary.cpp; sourceTree = "<group>"; };
 		BCE4413112F748E2009B84B8 /* RenderCombineText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCombineText.cpp; sourceTree = "<group>"; };
 		BCE4413212F748E2009B84B8 /* RenderCombineText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCombineText.h; sourceTree = "<group>"; };
 		BCE658FE0EA9248A007E4533 /* Theme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Theme.h; sourceTree = "<group>"; };
@@ -21937,8 +21933,6 @@
 				E125F83C182411E700D84CD9 /* JSCryptoOperationData.h */,
 				9BD4E9141C462872005065BC /* JSCustomElementInterface.cpp */,
 				9BD4E9151C462872005065BC /* JSCustomElementInterface.h */,
-				BCE438A1140C0DBF005E437E /* JSDictionary.cpp */,
-				BCE4389B140B1BA7005E437E /* JSDictionary.h */,
 				93B70D4709EB0C7C009D8468 /* JSDOMBinding.cpp */,
 				93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */,
 				413C2C331BC29A7B0075204C /* JSDOMConstructor.h */,
@@ -26090,7 +26084,6 @@
 				FDA15ED212B03F94003A583A /* JSDelayNode.h in Headers */,
 				31FB1A66120A5D3F00DC02A0 /* JSDeviceMotionEvent.h in Headers */,
 				59A86008119DAFA100DEF1EF /* JSDeviceOrientationEvent.h in Headers */,
-				BCE4389C140B1BA8005E437E /* JSDictionary.h in Headers */,
 				659DDC8309E198BA001BF3C6 /* JSDocument.h in Headers */,
 				1221E05E1C02B444006A1A00 /* JSDocumentAnimation.h in Headers */,
 				ADDA94C219687AA500453029 /* JSDocumentCustom.h in Headers */,
@@ -29827,7 +29820,6 @@
 				31FB1A6C120A5D6900DC02A0 /* JSDeviceMotionEventCustom.cpp in Sources */,
 				59A86006119DAF7F00DEF1EF /* JSDeviceOrientationEvent.cpp in Sources */,
 				590E1B4B11E4EF700069F784 /* JSDeviceOrientationEventCustom.cpp in Sources */,
-				BCE438A2140C0DC0005E437E /* JSDictionary.cpp in Sources */,
 				659DDC8209E198BA001BF3C6 /* JSDocument.cpp in Sources */,
 				1221E05D1C02B444006A1A00 /* JSDocumentAnimation.cpp in Sources */,
 				49C7BA8D1042F5B10009D447 /* JSDocumentCustom.cpp in Sources */,

Modified: trunk/Source/WebCore/bindings/js/Dictionary.cpp (209673 => 209674)


--- trunk/Source/WebCore/bindings/js/Dictionary.cpp	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/bindings/js/Dictionary.cpp	2016-12-10 22:13:58 UTC (rev 209674)
@@ -26,10 +26,8 @@
 #include "config.h"
 #include "Dictionary.h"
 
-#if ENABLE(NOTIFICATIONS)
-#include "JSNotification.h"
-#include "Notification.h"
-#endif
+#include "ArrayValue.h"
+#include "JSDOMConvert.h"
 
 using namespace JSC;
 
@@ -36,63 +34,46 @@
 namespace WebCore {
 
 Dictionary::Dictionary()
-    : m_dictionary(0, 0)
 {
 }
 
-Dictionary::Dictionary(JSC::ExecState* exec, JSC::JSValue value)
-    : m_dictionary(exec, value.isObject() ? value.getObject() : 0)
+Dictionary::Dictionary(ExecState* state, JSObject* initializerObject)
+    : m_state(state)
 {
+    if (state && initializerObject)
+        m_initializerObject = Strong<JSObject>(state->vm(), initializerObject);
 }
 
-
-#if ENABLE(NOTIFICATIONS)
-template<>
-JSObject* Dictionary::asJSObject<Notification>(Notification* object) const
+Dictionary::Dictionary(ExecState* state, JSValue value)
+    : Dictionary(state, value.isObject() ? value.getObject() : nullptr)
 {
-    return asObject(toJS(m_dictionary.execState(), jsCast<JSDOMGlobalObject*>(m_dictionary.execState()->lexicalGlobalObject()), object));
 }
-#endif
 
-bool Dictionary::getOwnPropertiesAsStringHashMap(HashMap<String, String>& map) const
+Dictionary::GetPropertyResult Dictionary::tryGetProperty(const char* propertyName, JSValue& finalResult) const
 {
-    if (!m_dictionary.isValid())
-        return false;
+    ASSERT(isValid());
 
-    JSObject* object =  m_dictionary.initializerObject();
-    ExecState* exec = m_dictionary.execState();
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    PropertyNameArray propertyNames(exec, PropertyNameMode::Strings);
-    JSObject::getOwnPropertyNames(object, exec, propertyNames, EnumerationMode());
-    for (PropertyNameArray::const_iterator it = propertyNames.begin(); it != propertyNames.end(); ++it) {
-        String stringKey = it->string();
-        if (stringKey.isEmpty())
-            continue;
-        JSValue value = object->get(exec, *it);
-        if (UNLIKELY(scope.exception()))
-            continue;
-        String stringValue = value.toString(exec)->value(exec);
-        if (LIKELY(!scope.exception()))
-            map.set(stringKey, stringValue);
-    }
-
-    return true;
+    auto scope = DECLARE_THROW_SCOPE(m_state->vm());
+    auto identifier = Identifier::fromString(m_state, propertyName);
+    bool propertyFound = m_initializerObject.get()->getPropertySlot(m_state, identifier, [&] (bool propertyFound, PropertySlot& slot) -> bool {
+        if (!propertyFound)
+            return false;
+        finalResult = slot.getValue(m_state, identifier);
+        return true;
+    });
+    RETURN_IF_EXCEPTION(scope, ExceptionThrown);
+    return propertyFound ? PropertyFound : NoPropertyFound;
 }
 
 bool Dictionary::getOwnPropertyNames(Vector<String>& names) const
 {
-    if (!m_dictionary.isValid())
+    if (!isValid())
         return false;
 
-    JSObject* object =  m_dictionary.initializerObject();
-    ExecState* exec = m_dictionary.execState();
-
-    PropertyNameArray propertyNames(exec, PropertyNameMode::Strings);
-    JSObject::getOwnPropertyNames(object, exec, propertyNames, EnumerationMode());
-    for (PropertyNameArray::const_iterator it = propertyNames.begin(); it != propertyNames.end(); ++it) {
-        String stringKey = it->string();
+    PropertyNameArray propertyNames(m_state, PropertyNameMode::Strings);
+    JSObject::getOwnPropertyNames(m_initializerObject.get(), m_state, propertyNames, EnumerationMode());
+    for (auto& identifier : propertyNames) {
+        auto stringKey = identifier.string();
         if (!stringKey.isEmpty())
             names.append(stringKey);
     }
@@ -100,9 +81,55 @@
     return true;
 }
 
-bool Dictionary::getWithUndefinedOrNullCheck(const char* propertyName, String& value) const
+// MARK: - Value conversions
+
+void Dictionary::convertValue(ExecState& state, JSValue value, bool& result)
 {
-    return m_dictionary.getWithUndefinedOrNullCheck(propertyName, value);
+    result = convert<IDLBoolean>(state, value);
 }
 
-};
+void Dictionary::convertValue(ExecState& state, JSValue value, int& result)
+{
+    result = convert<IDLLong>(state, value);
+}
+
+void Dictionary::convertValue(ExecState& state, JSValue value, unsigned& result)
+{
+    result = convert<IDLUnsignedLong>(state, value);
+}
+
+void Dictionary::convertValue(ExecState& state, JSValue value, unsigned short& result)
+{
+    result = convert<IDLUnsignedShort>(state, value);
+}
+
+void Dictionary::convertValue(ExecState& state, JSValue value, double& result)
+{
+    result = convert<IDLDouble>(state, value);
+}
+
+void Dictionary::convertValue(ExecState& state, JSValue value, String& result)
+{
+    result = convert<IDLDOMString>(state, value);
+}
+
+void Dictionary::convertValue(ExecState& state, JSValue value, Vector<String>& result)
+{
+    if (value.isUndefinedOrNull())
+        return;
+    result = convert<IDLSequence<IDLDOMString>>(state, value);
+}
+
+void Dictionary::convertValue(ExecState& state, JSValue value, Dictionary& result)
+{
+    result = Dictionary(&state, value);
+}
+
+void Dictionary::convertValue(ExecState& state, JSValue value, ArrayValue& result)
+{
+    if (value.isUndefinedOrNull())
+        return;
+    result = ArrayValue(&state, value);
+}
+
+}

Modified: trunk/Source/WebCore/bindings/js/Dictionary.h (209673 => 209674)


--- trunk/Source/WebCore/bindings/js/Dictionary.h	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/bindings/js/Dictionary.h	2016-12-10 22:13:58 UTC (rev 209674)
@@ -26,52 +26,74 @@
 
 #pragma once
 
-#include "JSDictionary.h"
-#include "JSEventListener.h"
-#include <bindings/ScriptValue.h>
-#include <wtf/HashMap.h>
+#include <heap/Strong.h>
+#include <heap/StrongInlines.h>
+#include <interpreter/CallFrame.h>
+#include <runtime/JSCInlines.h>
+#include <wtf/Forward.h>
+#include <wtf/Optional.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
 namespace JSC {
+class JSObject;
 class JSValue;
 }
 
 namespace WebCore {
-class EventListener;
 
+class ArrayValue;
+
 class Dictionary {
 public:
     Dictionary();
+    Dictionary(JSC::ExecState*, JSC::JSObject*);
     Dictionary(JSC::ExecState*, JSC::JSValue);
 
     // Returns true if a value was found for the provided property.
     template<typename Result> bool get(const char* propertyName, Result&) const;
     template<typename Result> bool get(const String& propertyName, Result&) const;
-
     template<typename Result> std::optional<Result> get(const char* propertyName) const;
+    
+    bool isObject() const { return isValid(); }
+    bool isUndefinedOrNull() const { return !isValid(); }
 
-    template<typename T> RefPtr<EventListener> getEventListener(const char* propertyName, T* target) const;
-    template<typename T> RefPtr<EventListener> getEventListener(const String& propertyName, T* target) const;
-
-    bool isObject() const { return m_dictionary.isValid(); }
-    bool isUndefinedOrNull() const { return !m_dictionary.isValid(); }
-    bool getOwnPropertiesAsStringHashMap(HashMap<String, String>&) const;
     bool getOwnPropertyNames(Vector<String>&) const;
-    bool getWithUndefinedOrNullCheck(const char* propertyName, String& value) const;
+    bool getWithUndefinedOrNullCheck(const char* propertyName, String&) const;
 
-    JSC::ExecState* execState() const { return m_dictionary.execState(); }
-    JSC::JSObject* initializerObject() const { return m_dictionary.initializerObject(); }
+    JSC::ExecState* execState() const { return m_state; }
+    JSC::JSObject* initializerObject() const { return m_initializerObject.get(); }
 
 private:
-    template<typename T> JSC::JSObject* asJSObject(T*) const;
-    
-    JSDictionary m_dictionary;
+    bool isValid() const { return m_state && m_initializerObject; }
+
+    enum GetPropertyResult {
+        ExceptionThrown,
+        NoPropertyFound,
+        PropertyFound
+    };
+
+    template <typename Result>
+    GetPropertyResult tryGetPropertyAndResult(const char* propertyName, Result& context) const;
+    GetPropertyResult tryGetProperty(const char* propertyName, JSC::JSValue&) const;
+
+    static void convertValue(JSC::ExecState&, JSC::JSValue, bool& result);
+    static void convertValue(JSC::ExecState&, JSC::JSValue, int& result);
+    static void convertValue(JSC::ExecState&, JSC::JSValue, unsigned& result);
+    static void convertValue(JSC::ExecState&, JSC::JSValue, unsigned short& result);
+    static void convertValue(JSC::ExecState&, JSC::JSValue, double& result);
+    static void convertValue(JSC::ExecState&, JSC::JSValue, String& result);
+    static void convertValue(JSC::ExecState&, JSC::JSValue, Vector<String>& result);
+    static void convertValue(JSC::ExecState&, JSC::JSValue, Dictionary& result);
+    static void convertValue(JSC::ExecState&, JSC::JSValue, ArrayValue& result);
+
+    JSC::ExecState* m_state { nullptr };
+    JSC::Strong<JSC::JSObject> m_initializerObject;
 };
 
 template<typename Result> bool Dictionary::get(const char* propertyName, Result& result) const
 {
-    return m_dictionary.isValid() && m_dictionary.get(propertyName, result);
+    return isValid() && tryGetPropertyAndResult(propertyName, result) == PropertyFound;
 }
 
 template<typename Result> bool Dictionary::get(const String& propertyName, Result& result) const
@@ -87,17 +109,48 @@
     return result;
 }
 
-template<typename T> RefPtr<EventListener> Dictionary::getEventListener(const char* propertyName, T* target) const
+template <>
+inline bool Dictionary::get(const char* propertyName, JSC::JSValue& finalResult) const
 {
-    JSC::JSValue eventListener;
-    if (!get(propertyName, eventListener) || !eventListener || !eventListener.isObject())
-        return nullptr;
-    return JSEventListener::create(asObject(eventListener), asJSObject(target), true, currentWorld(execState()));
+    return tryGetProperty(propertyName, finalResult) == PropertyFound;
 }
 
-template<typename T> RefPtr<EventListener> Dictionary::getEventListener(const String& propertyName, T* target) const
+inline bool Dictionary::getWithUndefinedOrNullCheck(const char* propertyName, String& result) const
 {
-    return getEventListener(propertyName.utf8().data(), target);
+    ASSERT(isValid());
+
+    JSC::JSValue value;
+    if (!get(propertyName, value) || value.isUndefinedOrNull())
+        return false;
+
+    result = value.toWTFString(m_state);
+    return true;
 }
 
+template <typename Result>
+Dictionary::GetPropertyResult Dictionary::tryGetPropertyAndResult(const char* propertyName, Result& finalResult) const
+{
+    auto scope = DECLARE_THROW_SCOPE(m_state->vm());
+
+    JSC::JSValue value;
+    GetPropertyResult getPropertyResult = tryGetProperty(propertyName, value);
+    switch (getPropertyResult) {
+    case ExceptionThrown:
+        return getPropertyResult;
+    case PropertyFound: {
+        Result result;
+        convertValue(*m_state, value, result);
+
+        RETURN_IF_EXCEPTION(scope, ExceptionThrown);
+
+        finalResult = result;
+        break;
+    }
+    case NoPropertyFound:
+        break;
+    }
+
+    return getPropertyResult;
 }
+
+}

Modified: trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp (209673 => 209674)


--- trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp	2016-12-10 22:13:58 UTC (rev 209674)
@@ -65,7 +65,6 @@
 #include "JSDataCueCustom.cpp"
 #include "JSDataTransferCustom.cpp"
 #include "JSDeviceOrientationEventCustom.cpp"
-#include "JSDictionary.cpp"
 #include "JSDocumentCustom.cpp"
 #include "JSDocumentFragmentCustom.cpp"
 #include "JSElementCustom.cpp"

Modified: trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp (209673 => 209674)


--- trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp	2016-12-10 22:13:58 UTC (rev 209674)
@@ -37,11 +37,11 @@
 #include "CryptoAlgorithmRsaKeyParamsWithHashDeprecated.h"
 #include "CryptoAlgorithmRsaOaepParamsDeprecated.h"
 #include "CryptoAlgorithmRsaSsaParamsDeprecated.h"
+#include "Dictionary.h"
 #include "ExceptionCode.h"
 #include "JSCryptoOperationData.h"
 #include "JSDOMBinding.h"
 #include "JSDOMConvert.h"
-#include "JSDictionary.h"
 
 using namespace JSC;
 
@@ -75,7 +75,7 @@
             // This is partially because we don't implement it elsewhere in WebCore yet, and partially because
             // WebCrypto doesn't yet clearly specify what to do with non-present values in most cases anyway.
 
-            JSDictionary dictionary(exec, value.getObject());
+            Dictionary dictionary(exec, value.getObject());
             dictionary.get("name", algorithmName);
         }
     }
@@ -102,9 +102,9 @@
     return object->get(exec, Identifier::fromString(exec, name));
 }
 
-static bool getHashAlgorithm(JSDictionary& dictionary, CryptoAlgorithmIdentifier& result, HashRequirement isRequired)
+static bool getHashAlgorithm(Dictionary& dictionary, CryptoAlgorithmIdentifier& result, HashRequirement isRequired)
 {
-    // FXIME: Teach JSDictionary how to return JSValues, and use that to get hash element value.
+    // FXIME: Teach Dictionary how to return JSValues, and use that to get hash element value.
 
     ExecState* exec = dictionary.execState();
     VM& vm = exec->vm();
@@ -186,10 +186,10 @@
         return nullptr;
     }
 
-    JSDictionary jsDictionary(&state, value.getObject());
+    Dictionary dictionary(&state, value.getObject());
     auto result = adoptRef(*new CryptoAlgorithmHmacParamsDeprecated);
 
-    auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
+    auto success = getHashAlgorithm(dictionary, result->hash, HashRequirement::Required);
     ASSERT_UNUSED(scope, scope.exception() || success);
     if (!success)
         return nullptr;
@@ -207,15 +207,15 @@
         return nullptr;
     }
 
-    JSDictionary jsDictionary(&state, value.getObject());
+    Dictionary dictionary(&state, value.getObject());
     auto result = adoptRef(*new CryptoAlgorithmHmacKeyParamsDeprecated);
 
-    auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
+    auto success = getHashAlgorithm(dictionary, result->hash, HashRequirement::Required);
     ASSERT(scope.exception() || success);
     if (!success)
         return nullptr;
 
-    result->hasLength = jsDictionary.get("length", result->length);
+    result->hasLength = dictionary.get("length", result->length);
     RETURN_IF_EXCEPTION(scope, nullptr);
 
     return WTFMove(result);
@@ -231,7 +231,7 @@
         return nullptr;
     }
 
-    JSDictionary jsDictionary(&state, value.getObject());
+    Dictionary dictionary(&state, value.getObject());
     auto result = adoptRef(*new CryptoAlgorithmRsaKeyGenParamsDeprecated);
 
     JSValue modulusLengthValue = getProperty(&state, value.getObject(), "modulusLength");
@@ -251,7 +251,7 @@
     }
     result->publicExponent.append(publicExponentArray->data(), publicExponentArray->byteLength());
 
-    result->hasHash = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Optional); 
+    result->hasHash = getHashAlgorithm(dictionary, result->hash, HashRequirement::Optional); 
 
     return WTFMove(result);
 }
@@ -272,10 +272,10 @@
         return nullptr;
     }
 
-    JSDictionary jsDictionary(exec, value.getObject());
+    Dictionary dictionary(exec, value.getObject());
     auto result = adoptRef(*new CryptoAlgorithmRsaOaepParamsDeprecated);
 
-    auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
+    auto success = getHashAlgorithm(dictionary, result->hash, HashRequirement::Required);
     ASSERT(scope.exception() || success);
     if (!success)
         return nullptr;
@@ -308,10 +308,10 @@
         return nullptr;
     }
 
-    JSDictionary jsDictionary(&state, value.getObject());
+    Dictionary dictionary(&state, value.getObject());
     auto result = adoptRef(*new CryptoAlgorithmRsaSsaParamsDeprecated);
 
-    auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
+    auto success = getHashAlgorithm(dictionary, result->hash, HashRequirement::Required);
     ASSERT(scope.exception() || success);
     if (!success)
         return nullptr;

Deleted: trunk/Source/WebCore/bindings/js/JSDictionary.cpp (209673 => 209674)


--- trunk/Source/WebCore/bindings/js/JSDictionary.cpp	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/bindings/js/JSDictionary.cpp	2016-12-10 22:13:58 UTC (rev 209674)
@@ -1,378 +0,0 @@
-/*
- * Copyright (C) 2011, 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 "JSDictionary.h"
-
-#include "ArrayValue.h"
-#include "DOMWindow.h"
-#include "Dictionary.h"
-#include "JSCSSFontFaceRule.h"
-#include "JSDOMConvert.h"
-#include "JSDOMError.h"
-#include "JSDOMWindow.h"
-#include "JSEventTarget.h"
-#include "JSMessagePort.h"
-#include "JSNode.h"
-#include "JSStorage.h"
-#include "JSTrackCustom.h"
-#include "JSVoidCallback.h"
-#include "SerializedScriptValue.h"
-#include <runtime/JSTypedArrays.h>
-#include <wtf/HashSet.h>
-#include <wtf/MathExtras.h>
-#include <wtf/text/AtomicString.h>
-
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
-#include "JSWebKitMediaKeyError.h"
-#endif
-
-#if ENABLE(FETCH_API)
-#include "JSFetchHeaders.h"
-#endif
-
-#if ENABLE(MEDIA_STREAM)
-#include "JSMediaStream.h"
-#include "JSMediaStreamTrack.h"
-#include "JSOverconstrainedError.h"
-#endif
-
-#if ENABLE(WEB_RTC)
-#include "JSRTCRtpReceiver.h"
-#include "JSRTCRtpTransceiver.h"
-#endif
-
-
-#if ENABLE(GAMEPAD)
-#include "JSGamepad.h"
-#endif
-
-#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(TOUCH_EVENTS)
-#include "JSTouch.h"
-#include "JSTouchList.h"
-#endif
-
-using namespace JSC;
-
-namespace WebCore {
-
-JSDictionary::GetPropertyResult JSDictionary::tryGetProperty(const char* propertyName, JSValue& finalResult) const
-{
-    VM& vm = m_exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-    ASSERT(isValid());
-    Identifier identifier = Identifier::fromString(m_exec, propertyName);
-    bool propertyFound = m_initializerObject.get()->getPropertySlot(m_exec, identifier, [&] (bool propertyFound, PropertySlot& slot) -> bool {
-        if (!propertyFound)
-            return false;
-        finalResult = slot.getValue(m_exec, identifier);
-        return true;
-    });
-    RETURN_IF_EXCEPTION(scope, ExceptionThrown);
-    return propertyFound ? PropertyFound : NoPropertyFound;
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, bool& result)
-{
-    result = value.toBoolean(exec);
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, int& result)
-{
-    result = value.toInt32(exec);
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, long int& result)
-{
-    result = value.toInt32(exec);
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, unsigned& result)
-{
-    result = value.toUInt32(exec);
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, unsigned short& result)
-{
-    result = static_cast<unsigned short>(value.toUInt32(exec));
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, unsigned long& result)
-{
-    result = static_cast<unsigned long>(value.toUInt32(exec));
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, unsigned long long& result)
-{
-    double d = value.toNumber(exec);
-    doubleToInteger(d, result);
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, long long& result)
-{
-    double d = value.toNumber(exec);
-    result = llrint(d);
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, double& result)
-{
-    result = value.toNumber(exec);
-}
-
-void JSDictionary::convertValue(JSC::ExecState* exec, JSC::JSValue value, Dictionary& result)
-{
-    result = Dictionary(exec, value);
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, String& result)
-{
-    result = value.toString(exec)->value(exec);
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, Vector<String>& result)
-{
-    ASSERT(exec);
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (value.isUndefinedOrNull())
-        return;
-
-    unsigned length = 0;
-    JSObject* object = toJSSequence(*exec, value, length);
-    RETURN_IF_EXCEPTION(scope, void());
-
-    for (unsigned i = 0 ; i < length; ++i) {
-        JSValue itemValue = object->get(exec, i);
-        RETURN_IF_EXCEPTION(scope, void());
-        result.append(itemValue.toString(exec)->value(exec));
-    }
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, Deprecated::ScriptValue& result)
-{
-    result = Deprecated::ScriptValue(exec->vm(), value);
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, RefPtr<SerializedScriptValue>& result)
-{
-    result = SerializedScriptValue::create(*exec, value);
-}
-
-void JSDictionary::convertValue(ExecState* state, JSValue value, RefPtr<DOMWindow>& result)
-{
-    VM& vm = state->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    auto* window = JSDOMWindow::toWrapped(value);
-    if (UNLIKELY(!window) && !value.isUndefinedOrNull()) {
-        throwVMTypeError(state, scope, "Dictionary member is not of type Window");
-        return;
-    }
-    result = window;
-}
-
-void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<EventTarget>& result)
-{
-    result = JSEventTarget::toWrapped(value);
-}
-
-void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<Node>& result)
-{
-    result = JSNode::toWrapped(value);
-}
-
-void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<Storage>& result)
-{
-    result = JSStorage::toWrapped(value);
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, Vector<RefPtr<MessagePort>>& result)
-{
-    result = convert<IDLSequence<IDLInterface<MessagePort>>>(*exec, value);
-}
-
-#if ENABLE(VIDEO_TRACK)
-void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<TrackBase>& result)
-{
-    result = toTrack(value);
-}
-#endif
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, HashSet<AtomicString>& result)
-{
-    ASSERT(exec);
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    result.clear();
-
-    if (value.isUndefinedOrNull())
-        return;
-
-    unsigned length = 0;
-    JSObject* object = toJSSequence(*exec, value, length);
-    RETURN_IF_EXCEPTION(scope, void());
-
-    for (unsigned i = 0 ; i < length; ++i) {
-        JSValue itemValue = object->get(exec, i);
-        RETURN_IF_EXCEPTION(scope, void());
-        result.add(itemValue.toString(exec)->value(exec));
-    }
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, ArrayValue& result)
-{
-    if (value.isUndefinedOrNull())
-        return;
-
-    result = ArrayValue(exec, value);
-}
-
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<Uint8Array>& result)
-{
-    result = toUnsharedUint8Array(value);
-}
-
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<WebKitMediaKeyError>& result)
-{
-    result = JSWebKitMediaKeyError::toWrapped(value);
-}
-#endif
-
-#if ENABLE(FETCH_API)
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<FetchHeaders>& result)
-{
-    result = JSFetchHeaders::toWrapped(value);
-}
-#endif
-
-#if ENABLE(MEDIA_STREAM)
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<MediaStream>& result)
-{
-    result = JSMediaStream::toWrapped(value);
-}
-
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<MediaStreamTrack>& result)
-{
-    result = JSMediaStreamTrack::toWrapped(value);
-}
-
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<OverconstrainedError>& result)
-{
-    result = JSOverconstrainedError::toWrapped(value);
-}
-#endif
-
-#if ENABLE(WEB_RTC)
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<RTCRtpReceiver>& result)
-{
-    result = JSRTCRtpReceiver::toWrapped(value);
-}
-
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<RTCRtpTransceiver>& result)
-{
-    result = JSRTCRtpTransceiver::toWrapped(value);
-}
-
-void JSDictionary::convertValue(ExecState* exec, JSValue value, Vector<RefPtr<MediaStream>>& result)
-{
-    ASSERT(exec);
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (value.isUndefinedOrNull())
-        return;
-
-    unsigned length = 0;
-    JSObject* object = toJSSequence(*exec, value, length);
-    RETURN_IF_EXCEPTION(scope, void());
-
-    for (unsigned i = 0 ; i < length; ++i) {
-        JSValue itemValue = object->get(exec, i);
-        RETURN_IF_EXCEPTION(scope, void());
-
-        auto stream = JSMediaStream::toWrapped(itemValue);
-        if (!stream) {
-            setDOMException(exec, TypeError);
-            return;
-        }
-        result.append(stream);
-    }
-}
-#endif
-
-#if ENABLE(FONT_LOAD_EVENTS)
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<CSSFontFaceRule>& result)
-{
-    result = JSCSSFontFaceRule::toWrapped(value);
-}
-
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<DOMError>& result)
-{
-    result = JSDOMError::toWrapped(value);
-}
-
-void JSDictionary::convertValue(JSC::ExecState* exec, JSC::JSValue value, RefPtr<VoidCallback>& result)
-{
-    if (!value.isFunction())
-        return;
-
-    result = JSVoidCallback::create(asObject(value), jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()));
-}
-#endif
-
-#if ENABLE(GAMEPAD)
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<Gamepad>& result)
-{
-    result = JSGamepad::toWrapped(value);
-}
-#endif
-
-#if ENABLE(TOUCH_EVENTS)
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<TouchList>& result)
-{
-    result = JSTouchList::toWrapped(value);
-}
-#endif
-
-void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, JSC::JSFunction*& result)
-{
-    result = jsDynamicDowncast<JSC::JSFunction*>(value);
-}
-
-bool JSDictionary::getWithUndefinedOrNullCheck(const char* propertyName, String& result) const
-{
-    ASSERT(isValid());
-    JSValue value;
-    if (tryGetProperty(propertyName, value) != PropertyFound || value.isUndefinedOrNull())
-        return false;
-
-    result = value.toWTFString(m_exec);
-    return true;
-}
-
-} // namespace WebCore

Deleted: trunk/Source/WebCore/bindings/js/JSDictionary.h (209673 => 209674)


--- trunk/Source/WebCore/bindings/js/JSDictionary.h	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/bindings/js/JSDictionary.h	2016-12-10 22:13:58 UTC (rev 209674)
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#pragma once
-
-#include "MessagePort.h"
-#include <heap/Strong.h>
-#include <heap/StrongInlines.h>
-#include <interpreter/CallFrame.h>
-#include <runtime/JSCInlines.h>
-#include <runtime/Uint8Array.h>
-#include <wtf/Forward.h>
-#include <wtf/Optional.h>
-
-namespace Deprecated {
-class ScriptValue;
-}
-
-namespace WebCore {
-
-class ArrayValue;
-class CSSFontFaceRule;
-class Dictionary;
-class DOMError;
-class DOMWindow;
-class EventTarget;
-class Gamepad;
-class FetchHeaders;
-class MediaStream;
-class MediaStreamTrack;
-class OverconstrainedError;
-class RTCRtpReceiver;
-class RTCRtpTransceiver;
-class Node;
-class SerializedScriptValue;
-class Storage;
-class TouchList;
-class TrackBase;
-class VoidCallback;
-class WebKitMediaKeyError;
-
-class JSDictionary {
-public:
-    JSDictionary(JSC::ExecState* exec, JSC::JSObject* initializerObject)
-        : m_exec(exec)
-    {
-        if (exec && initializerObject)
-            m_initializerObject = JSC::Strong<JSC::JSObject>(exec->vm(), initializerObject);
-    }
-
-    // Returns false if any exceptions were thrown, regardless of whether the property was found.
-    template <typename Result>
-    bool tryGetProperty(const char* propertyName, Result&) const;
-    template <typename T, typename Result>
-    bool tryGetProperty(const char* propertyName, T* context, void (*setter)(T* context, const Result&)) const;
-
-    // Returns true if the property was found in the dictionary, and the value could be converted to the desired type.
-    template <typename Result>
-    bool get(const char* propertyName, Result&) const;
-    bool getWithUndefinedOrNullCheck(const char* propertyName, String& value) const;
-
-    JSC::ExecState* execState() const { return m_exec; }
-    JSC::JSObject* initializerObject() const { return m_initializerObject.get(); }
-    bool isValid() const { return m_exec && m_initializerObject; }
-
-private:
-    template <typename Result>
-    struct IdentitySetter {
-        static void identitySetter(Result* context, const Result& result)
-        {
-            *context = result;
-        }
-    };
-
-    enum GetPropertyResult {
-        ExceptionThrown,
-        NoPropertyFound,
-        PropertyFound
-    };
-    
-    template <typename T, typename Result>
-    GetPropertyResult tryGetPropertyAndResult(const char* propertyName, T* context, void (*setter)(T* context, const Result&)) const;
-    GetPropertyResult tryGetProperty(const char* propertyName, JSC::JSValue&) const;
-
-    template <typename T>
-    static void convertValue(JSC::ExecState* execState, JSC::JSValue value, std::optional<T>& result)
-    {
-        if (value.isUndefinedOrNull()) {
-            result = std::nullopt;
-            return;
-        }
-
-        T actualResult;
-        convertValue(execState, value, actualResult);
-        result = actualResult;
-    }
-    
-    static void convertValue(JSC::ExecState*, JSC::JSValue, bool& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, int& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, long int& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, unsigned& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, unsigned short& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, unsigned long& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, unsigned long long& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, long long& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, double& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, Dictionary& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, String& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, Deprecated::ScriptValue& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, Vector<String>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<SerializedScriptValue>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<DOMWindow>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<EventTarget>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Node>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Storage>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, Vector<RefPtr<MessagePort>>& result);
-#if ENABLE(VIDEO_TRACK)
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<TrackBase>& result);
-#endif
-    static void convertValue(JSC::ExecState*, JSC::JSValue, HashSet<AtomicString>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, ArrayValue& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<JSC::Uint8Array>& result);
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<WebKitMediaKeyError>& result);
-#endif
-#if ENABLE(FETCH_API)
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<FetchHeaders>& result);
-#endif
-#if ENABLE(MEDIA_STREAM)
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<MediaStream>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<MediaStreamTrack>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<OverconstrainedError>& result);
-#endif
-#if ENABLE(WEB_RTC)
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<RTCRtpReceiver>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<RTCRtpTransceiver>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, Vector<RefPtr<MediaStream>>& result);
-#endif
-#if ENABLE(FONT_LOAD_EVENTS)
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<CSSFontFaceRule>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<DOMError>& result);
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<VoidCallback>& result);
-#endif
-#if ENABLE(GAMEPAD)
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Gamepad>&);
-#endif
-    static void convertValue(JSC::ExecState*, JSC::JSValue, JSC::JSFunction*&);
-#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(TOUCH_EVENTS)
-    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<TouchList>&);
-#endif
-
-    JSC::ExecState* m_exec;
-    JSC::Strong<JSC::JSObject> m_initializerObject;
-};
-
-template <typename T, typename Result>
-bool JSDictionary::tryGetProperty(const char* propertyName, T* context, void (*setter)(T* context, const Result&)) const
-{
-    return tryGetPropertyAndResult(propertyName, context, setter) != ExceptionThrown;
-}
-
-template <typename Result>
-bool JSDictionary::tryGetProperty(const char* propertyName, Result& finalResult) const
-{
-    return tryGetPropertyAndResult(propertyName, &finalResult, IdentitySetter<Result>::identitySetter) != ExceptionThrown;
-}
-
-template <typename Result>
-bool JSDictionary::get(const char* propertyName, Result& finalResult) const
-{
-    return tryGetPropertyAndResult(propertyName, &finalResult, IdentitySetter<Result>::identitySetter) == PropertyFound;
-}
-
-template <>
-inline bool JSDictionary::get(const char* propertyName, JSC::JSValue& finalResult) const
-{
-    return tryGetProperty(propertyName, finalResult) == PropertyFound;
-}
-
-template <typename T, typename Result>
-JSDictionary::GetPropertyResult JSDictionary::tryGetPropertyAndResult(const char* propertyName, T* context, void (*setter)(T* context, const Result&)) const
-{
-    JSC::VM& vm = m_exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSC::JSValue value;
-    GetPropertyResult getPropertyResult = tryGetProperty(propertyName, value);
-    switch (getPropertyResult) {
-    case ExceptionThrown:
-        return getPropertyResult;
-    case PropertyFound: {
-        Result result;
-        convertValue(m_exec, value, result);
-
-        RETURN_IF_EXCEPTION(scope, ExceptionThrown);
-
-        setter(context, result);
-        break;
-    }
-    case NoPropertyFound:
-        break;
-    }
-
-    return getPropertyResult;
-}
-
-} // namespace WebCore

Modified: trunk/Source/WebCore/dom/MutationObserver.cpp (209673 => 209674)


--- trunk/Source/WebCore/dom/MutationObserver.cpp	2016-12-10 21:04:05 UTC (rev 209673)
+++ trunk/Source/WebCore/dom/MutationObserver.cpp	2016-12-10 22:13:58 UTC (rev 209674)
@@ -32,7 +32,6 @@
 
 #include "MutationObserver.h"
 
-#include "Dictionary.h"
 #include "Document.h"
 #include "ExceptionCode.h"
 #include "HTMLSlotElement.h"
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to