diff options
| author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-05-24 08:28:08 +0000 |
|---|---|---|
| committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-05-24 08:28:08 +0000 |
| commit | a4e969f4965059196ca948db781e52f7cfebf19e (patch) | |
| tree | 6ca352808c8fdc52006a0f33f6ae3c593b23867d /Source/JavaScriptCore/bindings | |
| parent | 41386e9cb918eed93b3f13648cbef387e371e451 (diff) | |
| download | WebKitGtk-tarball-a4e969f4965059196ca948db781e52f7cfebf19e.tar.gz | |
webkitgtk-2.12.3webkitgtk-2.12.3
Diffstat (limited to 'Source/JavaScriptCore/bindings')
| -rw-r--r-- | Source/JavaScriptCore/bindings/ScriptFunctionCall.cpp | 13 | ||||
| -rw-r--r-- | Source/JavaScriptCore/bindings/ScriptFunctionCall.h | 2 | ||||
| -rw-r--r-- | Source/JavaScriptCore/bindings/ScriptObject.cpp | 2 | ||||
| -rw-r--r-- | Source/JavaScriptCore/bindings/ScriptValue.cpp | 37 | ||||
| -rw-r--r-- | Source/JavaScriptCore/bindings/ScriptValue.h | 6 |
5 files changed, 32 insertions, 28 deletions
diff --git a/Source/JavaScriptCore/bindings/ScriptFunctionCall.cpp b/Source/JavaScriptCore/bindings/ScriptFunctionCall.cpp index f2647da29..d6745bebc 100644 --- a/Source/JavaScriptCore/bindings/ScriptFunctionCall.cpp +++ b/Source/JavaScriptCore/bindings/ScriptFunctionCall.cpp @@ -32,6 +32,7 @@ #include "config.h" #include "ScriptFunctionCall.h" +#include "JSCInlines.h" #include "JSLock.h" #include "ScriptValue.h" #include <wtf/text/WTFString.h> @@ -120,7 +121,7 @@ Deprecated::ScriptValue ScriptFunctionCall::call(bool& hadException) JSLockHolder lock(m_exec); - JSValue function = thisObject->get(m_exec, Identifier(m_exec, m_name)); + JSValue function = thisObject->get(m_exec, Identifier::fromString(m_exec, m_name)); if (m_exec->hadException()) { hadException = true; return Deprecated::ScriptValue(); @@ -132,13 +133,15 @@ Deprecated::ScriptValue ScriptFunctionCall::call(bool& hadException) return Deprecated::ScriptValue(); JSValue result; + NakedPtr<Exception> exception; if (m_callHandler) - result = m_callHandler(m_exec, function, callType, callData, thisObject, m_arguments); + result = m_callHandler(m_exec, function, callType, callData, thisObject, m_arguments, exception); else - result = JSC::call(m_exec, function, callType, callData, thisObject, m_arguments); + result = JSC::call(m_exec, function, callType, callData, thisObject, m_arguments, exception); - if (m_exec->hadException()) { - hadException = true; + if (exception) { + // Do not treat a terminated execution exception as having an exception. Just treat it as an empty result. + hadException = !isTerminatedExecutionException(exception); return Deprecated::ScriptValue(); } diff --git a/Source/JavaScriptCore/bindings/ScriptFunctionCall.h b/Source/JavaScriptCore/bindings/ScriptFunctionCall.h index 04b2afe07..25cdfb214 100644 --- a/Source/JavaScriptCore/bindings/ScriptFunctionCall.h +++ b/Source/JavaScriptCore/bindings/ScriptFunctionCall.h @@ -71,7 +71,7 @@ private: class JS_EXPORT_PRIVATE ScriptFunctionCall : public ScriptCallArgumentHandler { public: - typedef JSC::JSValue (*ScriptFunctionCallHandler)(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args); + typedef JSC::JSValue (*ScriptFunctionCallHandler)(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>&); ScriptFunctionCall(const ScriptObject& thisObject, const String& name, ScriptFunctionCallHandler handler = nullptr); ScriptValue call(bool& hadException); ScriptValue call(); diff --git a/Source/JavaScriptCore/bindings/ScriptObject.cpp b/Source/JavaScriptCore/bindings/ScriptObject.cpp index ccf7af28f..70422e282 100644 --- a/Source/JavaScriptCore/bindings/ScriptObject.cpp +++ b/Source/JavaScriptCore/bindings/ScriptObject.cpp @@ -32,6 +32,8 @@ #include "config.h" #include "ScriptObject.h" +#include "JSCInlines.h" + using namespace JSC; namespace Deprecated { diff --git a/Source/JavaScriptCore/bindings/ScriptValue.cpp b/Source/JavaScriptCore/bindings/ScriptValue.cpp index c72ab4634..3e560dcc3 100644 --- a/Source/JavaScriptCore/bindings/ScriptValue.cpp +++ b/Source/JavaScriptCore/bindings/ScriptValue.cpp @@ -11,7 +11,7 @@ * 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -33,6 +33,7 @@ #include "APICast.h" #include "InspectorValues.h" #include "JSLock.h" +#include "StructureInlines.h" using namespace JSC; using namespace Inspector; @@ -96,8 +97,7 @@ bool ScriptValue::isFunction() const return getCallData(m_value.get(), callData) != CallTypeNone; } -#if ENABLE(INSPECTOR) -static PassRefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSValue value, int maxDepth) +static RefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSValue value, int maxDepth) { if (!value) { ASSERT_NOT_REACHED(); @@ -113,16 +113,16 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSV return InspectorValue::null(); if (value.isBoolean()) return InspectorBasicValue::create(value.asBoolean()); - if (value.isNumber()) + if (value.isNumber() && value.isDouble()) return InspectorBasicValue::create(value.asNumber()); - if (value.isString()) { - String s = value.getString(scriptState); - return InspectorString::create(String(s.deprecatedCharacters(), s.length())); - } + if (value.isNumber() && value.isMachineInt()) + return InspectorBasicValue::create(static_cast<int>(value.asMachineInt())); + if (value.isString()) + return InspectorString::create(value.getString(scriptState)); if (value.isObject()) { if (isJSArray(value)) { - RefPtr<InspectorArray> inspectorArray = InspectorArray::create(); + Ref<InspectorArray> inspectorArray = InspectorArray::create(); JSArray* array = asArray(value); unsigned length = array->length(); for (unsigned i = 0; i < length; i++) { @@ -130,34 +130,33 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSV RefPtr<InspectorValue> elementValue = jsToInspectorValue(scriptState, element, maxDepth); if (!elementValue) return nullptr; - inspectorArray->pushValue(elementValue); + inspectorArray->pushValue(WTFMove(elementValue)); } - return inspectorArray; + return WTFMove(inspectorArray); } - RefPtr<InspectorObject> inspectorObject = InspectorObject::create(); + Ref<InspectorObject> inspectorObject = InspectorObject::create(); JSObject* object = value.getObject(); - PropertyNameArray propertyNames(scriptState); - object->methodTable()->getOwnPropertyNames(object, scriptState, propertyNames, ExcludeDontEnumProperties); + PropertyNameArray propertyNames(scriptState, PropertyNameMode::Strings); + object->methodTable()->getOwnPropertyNames(object, scriptState, propertyNames, EnumerationMode()); for (size_t i = 0; i < propertyNames.size(); i++) { - const Identifier& name = propertyNames[i]; + const Identifier& name = propertyNames[i]; JSValue propertyValue = object->get(scriptState, name); RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, propertyValue, maxDepth); if (!inspectorValue) return nullptr; - inspectorObject->setValue(String(name.deprecatedCharacters(), name.length()), inspectorValue); + inspectorObject->setValue(name.string(), WTFMove(inspectorValue)); } - return inspectorObject; + return WTFMove(inspectorObject); } ASSERT_NOT_REACHED(); return nullptr; } -PassRefPtr<InspectorValue> ScriptValue::toInspectorValue(ExecState* scriptState) const +RefPtr<InspectorValue> ScriptValue::toInspectorValue(ExecState* scriptState) const { JSLockHolder holder(scriptState); return jsToInspectorValue(scriptState, m_value.get(), InspectorValue::maxDepth); } -#endif // ENABLE(INSPECTOR) } // namespace Deprecated diff --git a/Source/JavaScriptCore/bindings/ScriptValue.h b/Source/JavaScriptCore/bindings/ScriptValue.h index d5fade90b..78a2ee9a3 100644 --- a/Source/JavaScriptCore/bindings/ScriptValue.h +++ b/Source/JavaScriptCore/bindings/ScriptValue.h @@ -33,6 +33,7 @@ #define ScriptValue_h #include "JSCJSValue.h" +#include "JSCJSValueInlines.h" #include "Operations.h" #include "Strong.h" #include "StrongInlines.h" @@ -51,6 +52,7 @@ public: ScriptValue(JSC::VM& vm, JSC::JSValue value) : m_value(vm, value) { } virtual ~ScriptValue(); + operator JSC::JSValue() const { return jsValue(); } JSC::JSValue jsValue() const { return m_value.get(); } bool getString(JSC::ExecState*, String& result) const; String toString(JSC::ExecState*) const; @@ -65,9 +67,7 @@ public: bool operator==(const ScriptValue& other) const { return m_value == other.m_value; } -#if ENABLE(INSPECTOR) - PassRefPtr<Inspector::InspectorValue> toInspectorValue(JSC::ExecState*) const; -#endif + RefPtr<Inspector::InspectorValue> toInspectorValue(JSC::ExecState*) const; private: JSC::Strong<JSC::Unknown> m_value; |
