Diff
Modified: trunk/Source/WebCore/ChangeLog (114000 => 114001)
--- trunk/Source/WebCore/ChangeLog 2012-04-12 17:16:46 UTC (rev 114000)
+++ trunk/Source/WebCore/ChangeLog 2012-04-12 17:23:45 UTC (rev 114001)
@@ -1,3 +1,43 @@
+2012-04-12 Jon Lee <[email protected]>
+
+ Implement Dictionary.h on mac (83472)
+ https://bugs.webkit.org/show_bug.cgi?id=83472
+ <rdar://problem/11209766>
+
+ Reviewed by Kentaro Hara.
+
+ A difference between Dictionary and JSDictionary makes it difficult to merge the two together and avoid
+ creating a confusing API. The boolean returned by Dictionary::get() represents whether the
+ property was found. The boolean returned by JSDictionary::tryGetProperty() represents whether an
+ exception was thrown.
+
+ * WebCore.xcodeproj/project.pbxproj: Add Dictionary.h and Dictionary.cpp.
+
+ * bindings/js/Dictionary.cpp: Added.
+ (WebCore::Dictionary::Dictionary):
+ (WebCore::Dictionary::get):
+ * bindings/js/Dictionary.h: Leverage JSDictionary's functionality to obtain the data.
+ (WebCore::Dictionary::isObject): Mark an unimplemented.
+ (WebCore::Dictionary::isUndefinedOrNull): Mark an unimplemented.
+ (WebCore::Dictionary::getWithUndefinedOrNullCheck): Mark an unimplemented.
+
+ * bindings/js/JSDictionary.cpp:
+ (WebCore::JSDictionary::tryGetProperty): Convert to a const function.
+ * bindings/js/JSDictionary.h:
+ (WebCore::JSDictionary::isValid):
+ (WebCore::JSDictionary::tryGetProperty): Convert to a const function.
+ (WebCore::JSDictionary::get): Similar to tryGetProperty(), but returns true if the
+ property was found, converting the value succeeded and the out parameter "result" was set.
+ (WebCore::JSDictionary::tryGetPropertyAndResult): Refactor tryGetProperty() to return the enum directly.
+
+ Change bindings scripts to use Dictionary constructor.
+ * bindings/js/IDBBindingUtilities.cpp: Remove createDictionaryFromValue().
+ * bindings/js/IDBBindingUtilities.h: Remove createDictionaryFromValue().
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (JSValueToNative): Update to remove IDBBindingUtilities.h dependency, and use Dictionary constructor.
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::jsTestObjPrototypeFunctionOptionsObject): Update expected generated output.
+
2012-04-12 Sami Kyostila <[email protected]>
[chromium] Fix threaded compositor HUD crash
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (114000 => 114001)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-04-12 17:16:46 UTC (rev 114000)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-04-12 17:23:45 UTC (rev 114001)
@@ -851,9 +851,11 @@
3128CA68147331520074C72A /* NotificationController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3128CA67147331520074C72A /* NotificationController.cpp */; };
3128CA6B147331630074C72A /* NotificationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3128CA6A147331630074C72A /* NotificationController.h */; };
312C0C41146DC6CC0016C911 /* Notification.h in Headers */ = {isa = PBXBuildFile; fileRef = 333F704F0FB49CA2008E12A6 /* Notification.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 312D67B11535691F00563D0D /* Dictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 312D67B01535691F00563D0D /* Dictionary.cpp */; };
31313F651443B35F006E2A90 /* FilterEffectRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31313F631443B35E006E2A90 /* FilterEffectRenderer.cpp */; };
31313F661443B35F006E2A90 /* FilterEffectRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 31313F641443B35E006E2A90 /* FilterEffectRenderer.h */; };
3138A9E51474434600B0ED12 /* StyleShader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3138A9E41474434600B0ED12 /* StyleShader.h */; };
+ 316023F01532C40C00D50FF4 /* Dictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 316023EF1532C40C00D50FF4 /* Dictionary.h */; settings = {ATTRIBUTES = (Private, ); }; };
31611E5A0E1C4DE000F6A579 /* JSWebKitCSSTransformValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31611E580E1C4DE000F6A579 /* JSWebKitCSSTransformValue.cpp */; };
31611E5B0E1C4DE000F6A579 /* JSWebKitCSSTransformValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 31611E590E1C4DE000F6A579 /* JSWebKitCSSTransformValue.h */; };
31611E610E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 31611E5E0E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.h */; };
@@ -7750,9 +7752,11 @@
31288E710E3005D6003619AE /* WebKitCSSKeyframesRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitCSSKeyframesRule.h; sourceTree = "<group>"; };
3128CA67147331520074C72A /* NotificationController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NotificationController.cpp; path = notifications/NotificationController.cpp; sourceTree = "<group>"; };
3128CA6A147331630074C72A /* NotificationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NotificationController.h; path = notifications/NotificationController.h; sourceTree = "<group>"; };
+ 312D67B01535691F00563D0D /* Dictionary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Dictionary.cpp; sourceTree = "<group>"; };
31313F631443B35E006E2A90 /* FilterEffectRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FilterEffectRenderer.cpp; sourceTree = "<group>"; };
31313F641443B35E006E2A90 /* FilterEffectRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilterEffectRenderer.h; sourceTree = "<group>"; };
3138A9E41474434600B0ED12 /* StyleShader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleShader.h; path = style/StyleShader.h; sourceTree = "<group>"; };
+ 316023EF1532C40C00D50FF4 /* Dictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Dictionary.h; sourceTree = "<group>"; };
31611E540E1C4D4A00F6A579 /* WebKitCSSTransformValue.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebKitCSSTransformValue.idl; sourceTree = "<group>"; };
31611E580E1C4DE000F6A579 /* JSWebKitCSSTransformValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitCSSTransformValue.cpp; sourceTree = "<group>"; };
31611E590E1C4DE000F6A579 /* JSWebKitCSSTransformValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitCSSTransformValue.h; sourceTree = "<group>"; };
@@ -19585,6 +19589,8 @@
14DFB33F0A7DF7630018F769 /* Derived Sources */,
BCD533630ED6848900887468 /* CachedScriptSourceProvider.h */,
93F8B3060A300FEA00F61AB8 /* CodeGeneratorJS.pm */,
+ 312D67B01535691F00563D0D /* Dictionary.cpp */,
+ 316023EF1532C40C00D50FF4 /* Dictionary.h */,
BC53DA61114314BD000D817E /* DOMObjectHashTableMap.cpp */,
BC53DA5F1143141A000D817E /* DOMObjectHashTableMap.h */,
BC53DA471143134D000D817E /* DOMWrapperWorld.cpp */,
@@ -24758,6 +24764,7 @@
CEDA12D7152CA1CB00D9E08D /* AlternativeTextClient.h in Headers */,
D72F6D7A153159A3001EE44E /* FlowThreadController.h in Headers */,
5740E83D1532DE1700760628 /* TreeScopeAdjuster.h in Headers */,
+ 316023F01532C40C00D50FF4 /* Dictionary.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -27763,6 +27770,7 @@
E1C2F24A1533A2120083F974 /* SettingsMac.mm in Sources */,
D72F6D79153159A3001EE44E /* FlowThreadController.cpp in Sources */,
5740E83C1532DE1700760628 /* TreeScopeAdjuster.cpp in Sources */,
+ 312D67B11535691F00563D0D /* Dictionary.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Added: trunk/Source/WebCore/bindings/js/Dictionary.cpp (0 => 114001)
--- trunk/Source/WebCore/bindings/js/Dictionary.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/js/Dictionary.cpp 2012-04-12 17:23:45 UTC (rev 114001)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2012 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 COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "Dictionary.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+Dictionary::Dictionary(JSC::ExecState* exec, JSC::JSValue value)
+ : m_dictionary(exec, value.isObject() ? value.getObject() : 0)
+{
+}
+
+template <typename Result>
+bool Dictionary::get(const String& propertyName, Result& result) const
+{
+ if (!m_dictionary.isValid())
+ return false;
+
+ return m_dictionary.get(propertyName.ascii().data(), result);
+}
+
+};
+
Modified: trunk/Source/WebCore/bindings/js/Dictionary.h (114000 => 114001)
--- trunk/Source/WebCore/bindings/js/Dictionary.h 2012-04-12 17:16:46 UTC (rev 114000)
+++ trunk/Source/WebCore/bindings/js/Dictionary.h 2012-04-12 17:23:45 UTC (rev 114001)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,44 +27,33 @@
#ifndef Dictionary_h
#define Dictionary_h
-#include "SerializedScriptValue.h"
-#include <wtf/HashSet.h>
-#include <wtf/text/AtomicString.h>
+#include "JSDictionary.h"
+#include "NotImplemented.h"
+#include "ScriptValue.h"
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+namespace JSC {
+class JSValue;
+}
+
namespace WebCore {
+class EventListener;
-class DOMStringList;
-class DOMWindow;
-class IDBKeyRange;
-class ScriptValue;
-class Storage;
-class TrackBase;
-
-// FIXME: Implement.
class Dictionary {
public:
- Dictionary() { }
+ Dictionary(JSC::ExecState*, JSC::JSValue);
- bool isObject() const { return false; }
- bool isUndefinedOrNull() const { return false; }
+ // Returns true if a value was found for the provided property.
+ template <typename Result>
+ bool get(const String& propertyName, Result&) const;
- bool get(const String&, bool&) const { return false; }
- bool get(const String&, int32_t&) const { return false; }
- bool get(const String&, double&) const { return false; }
- bool get(const String&, String&) const { return false; }
- bool get(const String&, ScriptValue&) const { return false; }
- bool get(const String&, unsigned short&) const { return false; }
- bool get(const String&, unsigned&) const { return false; }
- bool get(const String&, unsigned long long&) const { return false; }
- bool get(const String&, RefPtr<DOMWindow>&) const { return false; }
- bool get(const String&, RefPtr<Storage>&) const { return false; }
- bool get(const String&, MessagePortArray&) const { return false; }
-#if ENABLE(VIDEO_TRACK)
- bool get(const String&, RefPtr<TrackBase>&) const { return false; }
-#endif
- bool get(const String&, HashSet<AtomicString>&) const { return false; }
+ bool isObject() const { notImplemented(); return false; }
+ bool isUndefinedOrNull() const { notImplemented(); return false; }
+ bool getWithUndefinedOrNullCheck(const String&, String&) const { notImplemented(); return false; }
- bool getWithUndefinedOrNullCheck(const String&, String&) const { return false; }
+private:
+ JSDictionary m_dictionary;
};
}
Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp (114000 => 114001)
--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp 2012-04-12 17:16:46 UTC (rev 114000)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp 2012-04-12 17:23:45 UTC (rev 114001)
@@ -26,9 +26,7 @@
#include "config.h"
#if ENABLE(INDEXED_DATABASE)
-
#include "IDBBindingUtilities.h"
-#include "NotImplemented.h"
#include "IDBKey.h"
@@ -46,12 +44,6 @@
return 0;
}
-Dictionary createDictionaryFromValue(JSC::ExecState*, JSC::JSValue)
-{
- // FIXME: Implement Database Options.
- return Dictionary();
-}
-
} // namespace WebCore
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h (114000 => 114001)
--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h 2012-04-12 17:16:46 UTC (rev 114000)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h 2012-04-12 17:23:45 UTC (rev 114001)
@@ -37,7 +37,6 @@
class IDBKey;
PassRefPtr<IDBKey> createIDBKeyFromValue(JSC::ExecState*, JSC::JSValue);
-Dictionary createDictionaryFromValue(JSC::ExecState*, JSC::JSValue);
}
Modified: trunk/Source/WebCore/bindings/js/JSDictionary.cpp (114000 => 114001)
--- trunk/Source/WebCore/bindings/js/JSDictionary.cpp 2012-04-12 17:16:46 UTC (rev 114000)
+++ trunk/Source/WebCore/bindings/js/JSDictionary.cpp 2012-04-12 17:23:45 UTC (rev 114001)
@@ -42,7 +42,7 @@
namespace WebCore {
-JSDictionary::GetPropertyResult JSDictionary::tryGetProperty(const char* propertyName, JSValue& finalResult)
+JSDictionary::GetPropertyResult JSDictionary::tryGetProperty(const char* propertyName, JSValue& finalResult) const
{
Identifier identifier(m_exec, propertyName);
PropertySlot slot(m_initializerObject);
Modified: trunk/Source/WebCore/bindings/js/JSDictionary.h (114000 => 114001)
--- trunk/Source/WebCore/bindings/js/JSDictionary.h 2012-04-12 17:16:46 UTC (rev 114000)
+++ trunk/Source/WebCore/bindings/js/JSDictionary.h 2012-04-12 17:23:45 UTC (rev 114001)
@@ -48,12 +48,18 @@
{
}
+ // Returns false if any exceptions were thrown, regardless of whether the property was found.
template <typename Result>
- bool tryGetProperty(const char* propertyName, 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&));
+ 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 isValid() const { return m_exec && m_initializerObject; }
+
private:
template <typename Result>
struct IdentitySetter {
@@ -68,7 +74,10 @@
NoPropertyFound,
PropertyFound
};
- GetPropertyResult tryGetProperty(const char* propertyName, JSC::JSValue&);
+
+ 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;
static void convertValue(JSC::ExecState*, JSC::JSValue, bool& result);
static void convertValue(JSC::ExecState*, JSC::JSValue, int& result);
@@ -95,20 +104,38 @@
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 <typename T, typename Result>
-bool JSDictionary::tryGetProperty(const char* propertyName, T* context, void (*setter)(T* context, const Result&))
+JSDictionary::GetPropertyResult JSDictionary::tryGetPropertyAndResult(const char* propertyName, T* context, void (*setter)(T* context, const Result&)) const
{
JSC::JSValue value;
- switch (tryGetProperty(propertyName, value)) {
+ GetPropertyResult getPropertyResult = tryGetProperty(propertyName, value);
+ switch (getPropertyResult) {
case ExceptionThrown:
- return false;
+ return getPropertyResult;
case PropertyFound: {
Result result;
convertValue(m_exec, value, result);
if (m_exec->hadException())
- return false;
+ return ExceptionThrown;
setter(context, result);
break;
@@ -117,15 +144,9 @@
break;
}
- return true;
+ return getPropertyResult;
}
-template <typename Result>
-bool JSDictionary::tryGetProperty(const char* propertyName, Result& finalResult)
-{
- return tryGetProperty(propertyName, &finalResult, IdentitySetter<Result>::identitySetter);
-}
-
} // namespace WebCore
#endif // JSDictionary_h
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (114000 => 114001)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-04-12 17:16:46 UTC (rev 114000)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-04-12 17:23:45 UTC (rev 114001)
@@ -2918,9 +2918,8 @@
}
if ($type eq "Dictionary") {
- AddToImplIncludes("IDBBindingUtilities.h", $conditional);
AddToImplIncludes("Dictionary.h", $conditional);
- return "createDictionaryFromValue(exec, $value)";
+ return "exec, $value";
}
if ($type eq "DOMString[]") {
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (114000 => 114001)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2012-04-12 17:16:46 UTC (rev 114000)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2012-04-12 17:23:45 UTC (rev 114001)
@@ -1520,7 +1520,7 @@
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() < 1)
return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
- Dictionary oo(createDictionaryFromValue(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
+ Dictionary oo(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined));
if (exec->hadException())
return JSValue::encode(jsUndefined());
@@ -1530,7 +1530,7 @@
return JSValue::encode(jsUndefined());
}
- Dictionary ooo(createDictionaryFromValue(exec, MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined)));
+ Dictionary ooo(exec, MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined));
if (exec->hadException())
return JSValue::encode(jsUndefined());
impl->optionsObject(oo, ooo);