summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/inspector/InjectedScript.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
commit41386e9cb918eed93b3f13648cbef387e371e451 (patch)
treea97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/inspector/InjectedScript.cpp
parente15dd966d523731101f70ccf768bba12435a0208 (diff)
downloadWebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/inspector/InjectedScript.cpp')
-rw-r--r--Source/JavaScriptCore/inspector/InjectedScript.cpp141
1 files changed, 33 insertions, 108 deletions
diff --git a/Source/JavaScriptCore/inspector/InjectedScript.cpp b/Source/JavaScriptCore/inspector/InjectedScript.cpp
index 492060e68..a02f85fb4 100644
--- a/Source/JavaScriptCore/inspector/InjectedScript.cpp
+++ b/Source/JavaScriptCore/inspector/InjectedScript.cpp
@@ -32,13 +32,14 @@
#include "config.h"
#include "InjectedScript.h"
+#if ENABLE(INSPECTOR)
+
#include "InspectorValues.h"
-#include "JSCInlines.h"
#include "ScriptFunctionCall.h"
#include "ScriptObject.h"
#include <wtf/text/WTFString.h>
-using Inspector::Protocol::Array;
+using Inspector::TypeBuilder::Array;
namespace Inspector {
@@ -56,7 +57,7 @@ InjectedScript::~InjectedScript()
{
}
-void InjectedScript::evaluate(ErrorString& errorString, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
+void InjectedScript::evaluate(ErrorString* errorString, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject>* result, Inspector::TypeBuilder::OptOutput<bool>* wasThrown)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("evaluate"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(expression);
@@ -64,11 +65,10 @@ void InjectedScript::evaluate(ErrorString& errorString, const String& expression
function.appendArgument(includeCommandLineAPI);
function.appendArgument(returnByValue);
function.appendArgument(generatePreview);
- function.appendArgument(saveResult);
- makeEvalCall(errorString, function, result, wasThrown, savedResultIndex);
+ makeEvalCall(errorString, function, result, wasThrown);
}
-void InjectedScript::callFunctionOn(ErrorString& errorString, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown)
+void InjectedScript::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject>* result, Inspector::TypeBuilder::OptOutput<bool>* wasThrown)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("callFunctionOn"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
@@ -79,7 +79,7 @@ void InjectedScript::callFunctionOn(ErrorString& errorString, const String& obje
makeEvalCall(errorString, function, result, wasThrown);
}
-void InjectedScript::evaluateOnCallFrame(ErrorString& errorString, const Deprecated::ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
+void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, const Deprecated::ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject>* result, Inspector::TypeBuilder::OptOutput<bool>* wasThrown)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("evaluateOnCallFrame"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(callFrames);
@@ -89,112 +89,59 @@ void InjectedScript::evaluateOnCallFrame(ErrorString& errorString, const Depreca
function.appendArgument(includeCommandLineAPI);
function.appendArgument(returnByValue);
function.appendArgument(generatePreview);
- function.appendArgument(saveResult);
- makeEvalCall(errorString, function, result, wasThrown, savedResultIndex);
+ makeEvalCall(errorString, function, result, wasThrown);
}
-void InjectedScript::getFunctionDetails(ErrorString& errorString, const String& functionId, RefPtr<Inspector::Protocol::Debugger::FunctionDetails>* result)
+void InjectedScript::getFunctionDetails(ErrorString* errorString, const String& functionId, RefPtr<Inspector::TypeBuilder::Debugger::FunctionDetails>* result)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getFunctionDetails"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(functionId);
RefPtr<InspectorValue> resultValue;
makeCall(function, &resultValue);
- if (!resultValue || resultValue->type() != InspectorValue::Type::Object) {
+ if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
if (!resultValue->asString(errorString))
- errorString = ASCIILiteral("Internal error");
+ *errorString = ASCIILiteral("Internal error");
return;
}
- *result = BindingTraits<Inspector::Protocol::Debugger::FunctionDetails>::runtimeCast(WTF::move(resultValue));
+ *result = Inspector::TypeBuilder::Debugger::FunctionDetails::runtimeCast(resultValue);
}
-void InjectedScript::getProperties(ErrorString& errorString, const String& objectId, bool ownProperties, bool generatePreview, RefPtr<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>* properties)
+void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ownProperties, RefPtr<Array<Inspector::TypeBuilder::Runtime::PropertyDescriptor>>* properties)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getProperties"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
function.appendArgument(ownProperties);
- function.appendArgument(generatePreview);
-
- RefPtr<InspectorValue> result;
- makeCall(function, &result);
- if (!result || result->type() != InspectorValue::Type::Array) {
- errorString = ASCIILiteral("Internal error");
- return;
- }
-
- *properties = BindingTraits<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>::runtimeCast(WTF::move(result));
-}
-
-void InjectedScript::getDisplayableProperties(ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>* properties)
-{
- Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getDisplayableProperties"), inspectorEnvironment()->functionCallHandler());
- function.appendArgument(objectId);
- function.appendArgument(generatePreview);
RefPtr<InspectorValue> result;
makeCall(function, &result);
- if (!result || result->type() != InspectorValue::Type::Array) {
- errorString = ASCIILiteral("Internal error");
+ if (!result || result->type() != InspectorValue::TypeArray) {
+ *errorString = ASCIILiteral("Internal error");
return;
}
- *properties = BindingTraits<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>::runtimeCast(WTF::move(result));
+ *properties = Array<Inspector::TypeBuilder::Runtime::PropertyDescriptor>::runtimeCast(result);
}
-void InjectedScript::getInternalProperties(ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr<Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>* properties)
+void InjectedScript::getInternalProperties(ErrorString* errorString, const String& objectId, RefPtr<Array<Inspector::TypeBuilder::Runtime::InternalPropertyDescriptor>>* properties)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getInternalProperties"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(objectId);
- function.appendArgument(generatePreview);
RefPtr<InspectorValue> result;
makeCall(function, &result);
- if (!result || result->type() != InspectorValue::Type::Array) {
- errorString = ASCIILiteral("Internal error");
+ if (!result || result->type() != InspectorValue::TypeArray) {
+ *errorString = ASCIILiteral("Internal error");
return;
}
- auto array = BindingTraits<Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>::runtimeCast(WTF::move(result));
- *properties = array->length() > 0 ? array : nullptr;
+ RefPtr<Array<Inspector::TypeBuilder::Runtime::InternalPropertyDescriptor>> array = Array<Inspector::TypeBuilder::Runtime::InternalPropertyDescriptor>::runtimeCast(result);
+ if (array->length() > 0)
+ *properties = array;
}
-void InjectedScript::getCollectionEntries(ErrorString& errorString, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr<Protocol::Array<Protocol::Runtime::CollectionEntry>>* entries)
-{
- Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getCollectionEntries"), inspectorEnvironment()->functionCallHandler());
- function.appendArgument(objectId);
- function.appendArgument(objectGroup);
- function.appendArgument(startIndex);
- function.appendArgument(numberToFetch);
-
- RefPtr<InspectorValue> result;
- makeCall(function, &result);
- if (!result || result->type() != InspectorValue::Type::Array) {
- errorString = ASCIILiteral("Internal error");
- return;
- }
-
- *entries = BindingTraits<Array<Protocol::Runtime::CollectionEntry>>::runtimeCast(WTF::move(result));
-}
-
-void InjectedScript::saveResult(ErrorString& errorString, const String& callArgumentJSON, Inspector::Protocol::OptOutput<int>* savedResultIndex)
-{
- Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("saveResult"), inspectorEnvironment()->functionCallHandler());
- function.appendArgument(callArgumentJSON);
-
- RefPtr<InspectorValue> result;
- makeCall(function, &result);
- if (!result || result->type() != InspectorValue::Type::Integer) {
- errorString = ASCIILiteral("Internal error");
- return;
- }
-
- int savedResultIndexInt = 0;
- if (result->asInteger(savedResultIndexInt) && savedResultIndexInt > 0)
- *savedResultIndex = savedResultIndexInt;
-}
-
-Ref<Array<Inspector::Protocol::Debugger::CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames)
+PassRefPtr<Array<Inspector::TypeBuilder::Debugger::CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames)
{
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("wrapCallFrames"), inspectorEnvironment()->functionCallHandler());
@@ -204,13 +151,13 @@ Ref<Array<Inspector::Protocol::Debugger::CallFrame>> InjectedScript::wrapCallFra
Deprecated::ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
RefPtr<InspectorValue> result = callFramesValue.toInspectorValue(scriptState());
- if (result->type() == InspectorValue::Type::Array)
- return BindingTraits<Array<Inspector::Protocol::Debugger::CallFrame>>::runtimeCast(WTF::move(result)).releaseNonNull();
+ if (result->type() == InspectorValue::TypeArray)
+ return Array<Inspector::TypeBuilder::Debugger::CallFrame>::runtimeCast(result);
- return Array<Inspector::Protocol::Debugger::CallFrame>::create();
+ return Array<Inspector::TypeBuilder::Debugger::CallFrame>::create();
}
-RefPtr<Inspector::Protocol::Runtime::RemoteObject> InjectedScript::wrapObject(const Deprecated::ScriptValue& value, const String& groupName, bool generatePreview) const
+PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const Deprecated::ScriptValue& value, const String& groupName, bool generatePreview) const
{
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), ASCIILiteral("wrapObject"), inspectorEnvironment()->functionCallHandler());
@@ -224,14 +171,11 @@ RefPtr<Inspector::Protocol::Runtime::RemoteObject> InjectedScript::wrapObject(co
if (hadException)
return nullptr;
- RefPtr<InspectorObject> resultObject;
- bool castSucceeded = r.toInspectorValue(scriptState())->asObject(resultObject);
- ASSERT_UNUSED(castSucceeded, castSucceeded);
-
- return BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
+ RefPtr<InspectorObject> rawResult = r.toInspectorValue(scriptState())->asObject();
+ return Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
}
-RefPtr<Inspector::Protocol::Runtime::RemoteObject> InjectedScript::wrapTable(const Deprecated::ScriptValue& table, const Deprecated::ScriptValue& columns) const
+PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapTable(const Deprecated::ScriptValue& table, const Deprecated::ScriptValue& columns) const
{
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), ASCIILiteral("wrapTable"), inspectorEnvironment()->functionCallHandler());
@@ -247,28 +191,8 @@ RefPtr<Inspector::Protocol::Runtime::RemoteObject> InjectedScript::wrapTable(con
if (hadException)
return nullptr;
- RefPtr<InspectorObject> resultObject;
- bool castSucceeded = r.toInspectorValue(scriptState())->asObject(resultObject);
- ASSERT_UNUSED(castSucceeded, castSucceeded);
-
- return BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
-}
-
-void InjectedScript::setExceptionValue(const Deprecated::ScriptValue& value)
-{
- ASSERT(!hasNoValue());
- Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("setExceptionValue"), inspectorEnvironment()->functionCallHandler());
- function.appendArgument(value);
- RefPtr<InspectorValue> result;
- makeCall(function, &result);
-}
-
-void InjectedScript::clearExceptionValue()
-{
- ASSERT(!hasNoValue());
- Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("clearExceptionValue"), inspectorEnvironment()->functionCallHandler());
- RefPtr<InspectorValue> result;
- makeCall(function, &result);
+ RefPtr<InspectorObject> rawResult = r.toInspectorValue(scriptState())->asObject();
+ return Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
}
Deprecated::ScriptValue InjectedScript::findObjectById(const String& objectId) const
@@ -314,3 +238,4 @@ void InjectedScript::releaseObjectGroup(const String& objectGroup)
} // namespace Inspector
+#endif // ENABLE(INSPECTOR)