From 41386e9cb918eed93b3f13648cbef387e371e451 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Wed, 20 May 2015 09:56:07 +0000 Subject: webkitgtk-2.4.9 --- .../inspector/InjectedScriptManager.cpp | 43 +++++++++------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'Source/JavaScriptCore/inspector/InjectedScriptManager.cpp') diff --git a/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp b/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp index 1bac2ecbd..72d20df3e 100644 --- a/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp +++ b/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp @@ -12,7 +12,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 Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Computer, 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. * @@ -31,6 +31,8 @@ #include "config.h" #include "InjectedScriptManager.h" +#if ENABLE(INSPECTOR) + #include "Completion.h" #include "InjectedScriptHost.h" #include "InjectedScriptSource.h" @@ -58,6 +60,7 @@ InjectedScriptManager::~InjectedScriptManager() void InjectedScriptManager::disconnect() { discardInjectedScripts(); + m_injectedScriptHost = nullptr; } InjectedScriptHost* InjectedScriptManager::injectedScriptHost() @@ -92,19 +95,15 @@ int InjectedScriptManager::injectedScriptIdFor(ExecState* scriptState) InjectedScript InjectedScriptManager::injectedScriptForObjectId(const String& objectId) { - RefPtr parsedObjectId; - if (!InspectorValue::parseJSON(objectId, parsedObjectId)) - return InjectedScript(); - - RefPtr resultObject; - if (!parsedObjectId->asObject(resultObject)) - return InjectedScript(); - - long injectedScriptId = 0; - if (!resultObject->getInteger(ASCIILiteral("injectedScriptId"), injectedScriptId)) - return InjectedScript(); + RefPtr parsedObjectId = InspectorValue::parseJSON(objectId); + if (parsedObjectId && parsedObjectId->type() == InspectorValue::TypeObject) { + long injectedScriptId = 0; + bool success = parsedObjectId->asObject()->getNumber(ASCIILiteral("injectedScriptId"), &injectedScriptId); + if (success) + return m_idToInjectedScript.get(injectedScriptId); + } - return m_idToInjectedScript.get(injectedScriptId); + return InjectedScript(); } void InjectedScriptManager::discardInjectedScripts() @@ -116,19 +115,13 @@ void InjectedScriptManager::discardInjectedScripts() void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) { - for (auto& injectedScript : m_idToInjectedScript.values()) - injectedScript.releaseObjectGroup(objectGroup); -} - -void InjectedScriptManager::clearExceptionValue() -{ - for (auto& injectedScript : m_idToInjectedScript.values()) - injectedScript.clearExceptionValue(); + for (auto it = m_idToInjectedScript.begin(); it != m_idToInjectedScript.end(); ++it) + it->value.releaseObjectGroup(objectGroup); } String InjectedScriptManager::injectedScriptSource() { - return StringImpl::createWithoutCopying(InjectedScriptSource_js, sizeof(InjectedScriptSource_js)); + return String(reinterpret_cast(InjectedScriptSource_js), sizeof(InjectedScriptSource_js)); } Deprecated::ScriptObject InjectedScriptManager::createInjectedScript(const String& source, ExecState* scriptState, int id) @@ -139,9 +132,9 @@ Deprecated::ScriptObject InjectedScriptManager::createInjectedScript(const Strin JSGlobalObject* globalObject = scriptState->lexicalGlobalObject(); JSValue globalThisValue = scriptState->globalThisValue(); - NakedPtr evaluationException; + JSValue evaluationException; InspectorEvaluateHandler evaluateHandler = m_environment.evaluateHandler(); - JSValue functionValue = evaluateHandler(scriptState, sourceCode, globalThisValue, evaluationException); + JSValue functionValue = evaluateHandler(scriptState, sourceCode, globalThisValue, &evaluationException); if (evaluationException) return Deprecated::ScriptObject(); @@ -156,7 +149,6 @@ Deprecated::ScriptObject InjectedScriptManager::createInjectedScript(const Strin args.append(jsNumber(id)); JSValue result = JSC::call(scriptState, functionValue, callType, callData, globalThisValue, args); - scriptState->clearException(); if (result.isObject()) return Deprecated::ScriptObject(scriptState, result.getObject()); @@ -190,3 +182,4 @@ void InjectedScriptManager::didCreateInjectedScript(InjectedScript) } // namespace Inspector +#endif // ENABLE(INSPECTOR) -- cgit v1.2.1